Commit Graph

12738 Commits

Author SHA1 Message Date
Konstantin Belousov
1c32456953 Use type-independent formats for printing nlink_t and ino_t.
Extracted from:	ino64 work by gleb, mckusick
Discussed with:	mckusick
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
2017-01-06 16:59:33 +00:00
Hajimu UMEMOTO
f03f398cda When displaying netstat details with libxo in JSON
or XML modes, the value conversion for tcp6 and udp6
port numbers drops last digit.

PR:		215682
MFC after:	3 days
2017-01-05 11:44:27 +00:00
Xin LI
f193c8ce0d Use strlcpy and snprintf in netstat(1).
Expand inet6name() line buffer to NI_MAXHOST and use strlcpy/snprintf
in various places.

Reported by:	Anton Yuzhaninov <citrin citrin ru>
MFC after:	3 days
Differential Revision:	https://reviews.freebsd.org/D8916
2017-01-05 09:23:54 +00:00
Alan Somers
2277edc8a6 Misc Coverity fixes for tail(1)
CID 1006402:	Initialize stack variable
CID 271580:	Don't leak memory when ENOMEM.

Reported by:	Coverity
CID:		271580 1006402
MFC after:	4 weeks
Sponsored by:	Spectra Logic Corp
2017-01-04 23:22:34 +00:00
Alan Somers
398b756be8 Remove dead code in rpc_parse.c
It's been dead ever since it was imported from TI-RPC in 1995.  The dead
code is still present in Illumos today, but was removed from NetBSD in 2006.

Reported by:	Coverity
CID:		270097
Obtained from:	NetBSD
MFC after:	4 weeks
Sponsored by:	Spectra Logic Corp
2017-01-04 17:39:20 +00:00
Alan Somers
f9fe16497a Delete dead code in chat(8)
It's always been dead, ever since first import in 1994.  It's still dead in
OpenBSD's version, too.

Reported by:	Coverity
CID:		270586
MFC after:	4 weeks
Sponsored by:	Spectra Logic Corp
2017-01-04 16:24:40 +00:00
Xin LI
e16f0839c6 Restructure libz, place vendor files in contrib/zlib like other third
party software, this provides more standarized import workflow and
makes future upgrades easier.

The following files are new with this commit:

	zconf.h.in
	zlib.map
	zlib.pc.in

They are not connected to build, but were kept in tree for reference
for future maintenance.

All our local trivial changes were applied to contrib/zlib, and the
contrib/zlib vendor source code is intended to 100% match lib/libz
before this commit.

MFC after:	2 weeks
2017-01-04 09:30:47 +00:00
John Baldwin
48f7957436 Update libsysdecode for getfsstat() 'flags' argument changing to 'mode'.
As a followup to r310638, update libsysdecode (and kdump) to decode the
'mode' argument to getfsstat().  sysdecode_getfsstat_flags() has been
renamed to sysdecode_getfsstat_mode() and now treats the argument as an
enumerated value rather than a mask of flags.
2017-01-03 01:39:05 +00:00
Piotr Pawel Stefaniak
183668da96 indent(1): add a piece missed in r311138. 2017-01-02 20:49:24 +00:00
Piotr Pawel Stefaniak
86adac04b2 indent(1): add option -P for loading user-provided files as profiles
Without this change, indent(1) would only look to load options from ~/.indent.pro if it's there and -npro wasn't used on the command line. This option lets the user set their own path to the file.

Approved by:	pfg (mentor)
Differential Revision:	https://reviews.freebsd.org/D9010
2017-01-02 20:23:46 +00:00
Pedro F. Giffuni
fa81223743 patch(1): replace strnlen() with a simpler strlen().
Small style fix with here.

Pointed out by:	kib
2017-01-02 18:27:35 +00:00
Pedro F. Giffuni
4f548c1916 Revert r311106:
patch(1): extend the maximum length of a line from USHRT_MAX to UINT_MAX.

This doesn't really work for 32 bit platforms.

Pointed out by:	kib
2017-01-02 18:23:31 +00:00
Pedro F. Giffuni
ad8469feec patch(1): extend the maximum length of a line from USHRT_MAX to UINT_MAX.
We can handle such "big data" without much trouble.
Try to do a better job at detecting the rejection cause while here.

MFC after:	2 weeks
2017-01-02 17:12:14 +00:00
Baptiste Daroussin
d630035127 Remove extra entries from the option enum
MFC after:	3 days
2016-12-30 23:46:11 +00:00
Baptiste Daroussin
d481a92572 Make sdiff --left-column work as expected
MFC after:	3 days
2016-12-30 23:41:33 +00:00
Piotr Pawel Stefaniak
93567e8778 indent(1): Avoid out of bounds access of array ps.paren_indents
ps.p_l_follow can't be allowed to grow beyond maximum index of paren_indents.

Approved by:	pfg (mentor)
2016-12-30 21:00:45 +00:00
Dimitry Andric
30d4828e63 Reapply 310775, now it also builds correctly if lldb is disabled:
Move llvm-objdump from CLANG_EXTRAS to installed by default

We currently install three tools from binutils 2.17.50: as, ld, and
objdump. Work is underway to migrate to a permissively-licensed
tool-chain, with one goal being the retirement of binutils 2.17.50.

LLVM's llvm-objdump is intended to be compatible with GNU objdump
although it is currently missing some options and may have formatting
differences. Enable it by default for testing and further investigation.
It may later be changed to install as /usr/bin/objdump, it becomes a
fully viable replacement.

Reviewed by:	emaste
Differential Revision:	https://reviews.freebsd.org/D8879
2016-12-30 18:00:31 +00:00
Dimitry Andric
a222710ce2 Revert r310775 for now, until we can figure out why it does not seem to
work properly when cross-building.  Sorry for the breakage.
2016-12-29 21:57:16 +00:00
Dimitry Andric
1357722508 Move llvm-objdump from CLANG_EXTRAS to installed by default
We currently install three tools from binutils 2.17.50: as, ld, and
objdump. Work is underway to migrate to a permissively-licensed
tool-chain, with one goal being the retirement of binutils 2.17.50.

LLVM's llvm-objdump is intended to be compatible with GNU objdump
although it is currently missing some options and may have formatting
differences. Enable it by default for testing and further investigation.
It may later be changed to install as /usr/bin/objdump, it becomes a
fully viable replacement.

Reviewed by:	emaste
Differential Revision:	https://reviews.freebsd.org/D8879
2016-12-29 13:27:04 +00:00
Marius Strobl
ed7aec1e45 - Use correct offsets into the keys set array. As the elements of this
zero-length array are dynamically sized at run-time based on the use
  of hints, compilers can't be expected to figure out these offsets on
  their own. [1]
- Fix incorrect comparison in cmp_nans(). [2]

PR:		204571 [1], 202301 [2]
Submitted by:	David Binderman [2]
MFC after:	3 days
2016-12-28 17:13:03 +00:00
Marcelo Araujo
e9d2c20108 Print hostcache usage counts with TCP statistics.
PR:		196252
Submitted by:	Anton Yuzhaninov <citrin+pr@citrin.ru>
MFC after:	3 weeks.
2016-12-28 13:11:22 +00:00
Hiroki Sato
8f14a1af12 Fix gcc build.
Spotted by:	lidl
2016-12-24 22:51:02 +00:00
Hiroki Sato
39bb7275fb mdoc fixes. 2016-12-23 04:38:27 +00:00
Hiroki Sato
a04667ab17 - Add -S option to specify the source address/port for UDP communication.
- Document -S option.
- Document that -h option supports AF_LOCAL.
- Split preparation of UDP sockets in logmessage() into socksetup().
2016-12-22 23:39:11 +00:00
Simon J. Gerraty
45447996a0 Merge bmake-20161212 2016-12-19 23:38:07 +00:00
Conrad Meyer
1ea1b27578 ident(1): Capsicumify
Preopen input file list before entering Capsicum capability mode.

Feedback by:	allanjude@, bapt@, emaste@ (earlier versions)
Sponsored by:	Dell EMC Isilon
Differential Revision:	https://reviews.freebsd.org/D7918
2016-12-16 02:09:48 +00:00
Conrad Meyer
280dd9fc2e iconv(1): Capsicumify
This takes the usual shortcut of only sandboxing the last input file.
It's a first cut and this program will be easy to adapt to sandbox all
files in the future.

iconv(1) has been changed to only open the conversion descriptor once,
since the input and output encodings are fixed over all inputs.
Instead, the descriptor is simply reset after each use (documented in
iconv(3) API).

Reviewed by:	no one, unfortunately
Sponsored by:	Dell EMC Isilon
Differential Revision:	https://reviews.freebsd.org/D7917
2016-12-16 02:06:34 +00:00
Conrad Meyer
327240c75f hexdump(1): First cut capsicumification
For now, only enter the sandbox for the last file processed (including
stdin for zero-argument mode).

Sandboxing all inputs will require a little restructuring of the
program.

Feedback by:	emaste@ (earlier versions)
Sponsored by:	Dell EMC Isilon
Differential Revision:	https://reviews.freebsd.org/D7915
2016-12-16 02:03:40 +00:00
Conrad Meyer
208a859459 ktrdump(8): Capsicumify
We restrict the (optional) input file and output files. It would be
nice to restrict the KVM files, but that's up to libkvm.

We wait until after kvm_nlist() is invoked to cap_enter() because
kldsym() isn't supported in the Capsicum sandbox.

Feedback from:	emaste@ (earlier versions)
Sponsored by:	Dell EMC Isilon
Differential Revision:	https://reviews.freebsd.org/D7921
2016-12-16 01:59:28 +00:00
Conrad Meyer
20502a13a0 ministat(1): Capsicumify
Separate dataset opening from reading/parsing. The number of input
files is already capped to a small number, so just open all input files
before sandboxing.

Feedback from:	allanjude@ (earlier version), emaste@ (earlier version)
Sponsored by:	Dell EMC Isilon
Differential Revision:	https://reviews.freebsd.org/D7925
2016-12-16 01:51:12 +00:00
Conrad Meyer
941e22d17d Capsicumify last(1)
Reviewed by:	ed (earlier version), emaste (earlier version)
Sponsored by:	Dell EMC Isilon
Differential Revision:	https://reviews.freebsd.org/D8001
2016-12-16 01:47:08 +00:00
Eric van Gyzen
3d32d4a7c9 Export the whole thread name in kinfo_proc
kinfo_proc::ki_tdname is three characters shorter than
thread::td_name.  Add a ki_moretdname field for these three
extra characters.  Add the new field to kinfo_proc32, as well.
Update all in-tree consumers to read the new field and assemble
the full name, except for lldb's HostThreadFreeBSD.cpp, which
I will handle separately.  Bump __FreeBSD_version.

Reviewed by:	kib
MFC after:	1 week
Relnotes:	yes
Sponsored by:	Dell EMC
Differential Revision:	https://reviews.freebsd.org/D8722
2016-12-07 15:04:22 +00:00
Eric van Gyzen
b54d51ac86 locale: fix the powerpc build
Reported by:	markj (and bde, in a way)
MFC after:	3 days
X-MFC with:	r309364
Sponsored by:	Dell EMC
2016-12-06 15:42:18 +00:00
John Baldwin
1175b23f77 Rework syscall structure lookups.
Avoid always using an O(n^2) loop over known syscall structures with
strcmp() on each system call.  Instead, use a per-ABI cache indexed by
the system call number. The first 1024 system calls (which should cover
all of the normal system calls in currently-supported ABIs) use a flat array
indexed by the system call number to find system call structure.  For other
system calls, a linked list of structures storing an integer to structure
mapping is stored in the ABI.  The linked list isn't very smart, but it
should only be used by buggy applications invoking unknown system calls.

This also fixes handling of unknown system calls which currently trigger
a NULL pointer dereference.

Reviewed by:	kib
MFC after:	2 weeks
2016-12-06 00:39:00 +00:00
Sevan Janiyan
0e922aa308 Fix error in the example section
Adjust formatting highlighted by igor.

PR:		214683
Submitted by:	Anindya Mukherjee <anindya49 AT hotmail DOT com>
Reviewed by:	jilles
Approved by:	bcr (mentor)
MFC after:	5 days
Differential Revision:	https://reviews.freebsd.org/D8591
2016-12-05 13:23:22 +00:00
Pedro F. Giffuni
bde60d7544 indent(1): remove unneeded comma.
It is not a good practice to start a newline with a comma anyways.

Discussed with:	 bjk
Differential Revision:	https://reviews.freebsd.org/D8690
2016-12-04 03:10:25 +00:00
Pedro F. Giffuni
86bd08e9ee Document undocumented indent(1) options badp/nbadp, bs/nbs, and lc.
Submitted by:	 Piotr Stefaniak
Differential Revision:	https://reviews.freebsd.org/D8690
2016-12-03 00:24:34 +00:00
Pedro F. Giffuni
488f148604 indent(1): Avoid out-of-bound accesses of array ps.p_stack.
Submitted by:	 Piotr Stefaniak
2016-12-02 16:42:45 +00:00
Pedro F. Giffuni
0bae80a336 indent(1): Avoid out-of-bound accesses of arrays.
ps.paren_indents:
When ps.paren_level was 0, this was accessing paren_indents[-1].

in_buffer:
This fragment checks if "*/" was read, but there's no guarantee that there
is more than one byte in the array (actually, this happens frequently for
the "{" in things like "int main(void) {").

Submitted by:	 Piotr Stefaniak
2016-12-02 16:41:08 +00:00
Pedro F. Giffuni
df54a266d3 indent(1): Remove an extra newline added in a previous commit.
It doesn't math the remaining of the case statement.
2016-12-02 16:32:14 +00:00
Pedro F. Giffuni
b30bb755da indent(1): Optimize parser stack usage.
When special else-if processing is enabled (-ei), we can assume "else if"
and "if" to be equivalent for indentation purposes.
This reduction saves a lot of stack space in case of a long "if-else-if
... else-if" sequence;  with this change,
Postgres/src/bin/psql/tab-complete.c as of 9.6beta3
requires minimum of the stack length to be 31 instead of 444.

Submitted by:	 Piotr Sephaniak
2016-12-02 16:28:18 +00:00
Pedro F. Giffuni
cba6bdf9bc indent(1): Do not define opchar unless it will be used.
"opchar" is only used once depending on "undef" macro being defined.
Conditionalize it in the same way.

Submitted by:	Piotr Sephaniak
2016-12-02 01:52:32 +00:00
Pedro F. Giffuni
f171328eaa indent(1): Fix indent's confusion about custom FreeBSD macros.
Teach indent(1) about storage-class specifiers. Don't assume
"in_parameter_declaration" state if "in_decl" hasn't been set. Don't set
"in_decl" for storage-class specifiers.

That set of changes helps with recognizing the difference between file
scope declarations like this:

static LIST_HEAD(, alq) ald_active;
static int ald_shuttingdown = 0;
struct thread *ald_thread;

and old style function declarators like this:

static int
do_execve(td, args, mac_p)
	struct thread *td;
	struct image_args *args;
	struct mac *mac_p;
{

Unfortunately, at the same time this change makes indent(1) require
explicit int in declarations like "static a;", in order to understand that
it's part of a declaration. On the other hand, declarations like in the
first example are no longer indented as if ald_shuttingdown and ald_thread
were parameters of a function named LIST_HEAD.

Submitted by:	 Piotr Stefaniak
2016-12-02 01:25:51 +00:00
Eric van Gyzen
b28fd8ce86 locale: enable more warnings; fix them
Do not set WARNS, so it gets the current default of 6.
Fix the warnings by sprinkling static, const, or strdup.
Make some constant data tables const.  Fix whitespace.

MFC after:	1 week
Sponsored by:	Dell EMC
2016-12-01 17:36:31 +00:00
Eric van Gyzen
71500aab3e locale: fix buffer management
Also, handle signed and unsigned chars, and more gracefully handle
invalid input.

Submitted by:	bde in response to r309331
MFC after:	1 week
Sponsored by:	Dell EMC
2016-12-01 16:54:02 +00:00
Pedro F. Giffuni
909f007fb8 indent(1): Don't unnecessarily add a blank before a comment ends.
pr_comment() did avoid adding surplus space character when a comment
contained it at the end. Now it's also paying attention to tabs.

Taken from:	 Piotr Stefaniak
2016-12-01 01:56:34 +00:00
Pedro F. Giffuni
67b7daecf7 indent(1): Don't ignore newlines after comments that follow braces.
indent.c has a special loop that stores tokens from between an if () and
the next statement into a buffer. The loop ignored all newlines, but that
resulted in not calling dump_line() when it was needed to produce the
final line of the buffered up comment.

Taken from:	 Piotr Stefaniak
2016-12-01 01:48:56 +00:00
Pedro F. Giffuni
458051a57b indent(1): Avoid out of bound access of array in_buffer
Work-around a somewhat complex interaction within the code. From
Piotr's commit [1]:

When pr_comment() calls dump_line() for the first line of a multiline
comment, it doesn't include any indentation - it starts with the "/*".
This is consistent for both boxed and not boxed comments. Where the logic
diverges is in how it treats the rest of the lines of the comment. For box
comments indent assumes that it must not change anything, so lines are
dumped as they were, including the indentation where it exists. For the
rest of comments, it will first remove the indentation to store plain text
of the comment and then add it again where indent thinks it's appropriate
-- this is part of comment re-indenting process.

For continuations of multi-line comments, the code that handles comments
in dump_line() will use pad_output() to create indentation from the
beginning of the line (what indent calls the first column) and then write
string pointed by s_com afterwards. But if it's a box comment, the string
will include original indentation, unless it's the first line of the
comment. This is why tab characters from s_com have to be considered when
calculating how much padding is needed and the "while (*com_st == '\t')
com_st++, target += 8;" does that.

In dump_line(), /target/ is initially set to ps.com_col, so it always
assumes that indentation needs to be produced in this function, regardless
of which line of a box comment it is. But for the first line of a box
comment it is not true, so pr_comment() signals it by setting
ps.n_comment_delta, the negative comment delta, to a negative number which
is then added to /target/ in dump_line() on all lines except the first
one, so that the function produces adequate indentation in this special
case.

The bug was in how that negative offset was calculated: pr_comment() used
count_spaces() on in_buffer, which pr_comment() expected to contain
non-null terminated sequence of characters, originating from whatever
originally was on the left side of the comment. Understanding that
count_spaces() requires a string, pr_comment() temporarily set buf_ptr[-2]
to 0 in hope that it would nul-terminate the right thing in in_buffer and
calling count_spaces() would be safe and do the expected thing. This was
false whenever buf_ptr would point into save_com, an entirely different
char array than in_buffer.

The short-term fix is to recognize whether buf_ptr points into in_buffer
or save_com.

Reference:
[1]
ea486a2aa3

Taken from:	 Piotr Stefaniak
2016-12-01 01:32:13 +00:00
Eric van Gyzen
dc521a5840 Include limits.h for CHAR_MAX
This was needed on stable/10.  Apparently, sys/param.h supplies CHAR_MAX
on head.  Include limits.h anyway, for consistency, and because C says so.

Sponsored by:	Dell EMC
2016-11-30 18:34:40 +00:00
Robert Watson
f534f01f1a Clarify warning message when failing to configure audit on user login:
when au_user_mask() fails, it's not a failure to set the audit mask,
but to calculate the audit mask -- and hence a condfiguration-file
issue (of some sort).

MFC after:	3 days
Sponsored by:	DARPA, AFRL
2016-11-30 14:02:36 +00:00