The previous code had bug when reading lines with an unexpected
encoding, returning without the full line being captured.
This result in sort complaining with "sort: Illegal byte sequence"
Using getdelim(3) instead of the home made code, fixes the situation.
PR: 241679
Reported by: Ronald F. Guilmette <rfg-freebsd@tristatelogic.com>
MFC After: 1 week
Reviewed by: markj, imp
Differential Revision: https://reviews.freebsd.org/D36948
If we're writing structured output (i.e. json or xml) we shouldn't worry
about terminal width, and instead always output full width information.
This means that, for example, if we're called from crontab with 'w
--libxo json' we'll provide full the command field rather than
pointlessly truncating it.
Suggested by: Phil Shafer
Event: Aberdeen Hackathon 2022
Differential Revision: https://reviews.freebsd.org/D25013
When mac_veriexec is enforcing, we won't run unverified binaries,
don't let ldd examine them either.
Reviewed by: stevek emaste
MFC after: 1 week
Sponsored by: Juniper Networks, Inc.
Differential Revision: https://reviews.freebsd.org/D36897
Trying to exec malformed or unusual binary, for instance, a non-FreeBSD
ABI, or using a non-standard interpreter, might give unexpected outcome.
Reported by: The UK's National Cyber Security Centre (NCSC)
Reviewed by: emaste, markj, philip
Discussed with: jhb
Sponsored by: The FreeBSD Foundation
admbug: 991
PR: 127276, 175339, 231926
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D36650
If the next column was blank, then the length of the following entry
was computed as the end of the following entry minus a global variable
"blank" which is not in the same string or allocation. Instead, save
the start value of 'p' explicitly instead of abusing '*ep'. Possibly
we should just increment p before saving it in sp in the 'blank' case,
but at worst that would just mean maxlen might be one char too large
which should be harmless.
Reviewed by: brooks
Differential Revision: https://reviews.freebsd.org/D36832
Using a pointer passed to realloc() after realloc() even for pointer
arithmetic is UB. It also breaks in practice on CHERI systems as
the updated value of 'sp' in this case would have had the bounds from
the old allocation.
This would be much cleaner if elem were a std::vector<char *>.
Reviewed by: brooks, emaste
Reported by: GCC -Wuse-after-free
Differential Revision: https://reviews.freebsd.org/D36831
- Add /* FALLTHROUGH */ comments for intentional fall throughs in
getargs().
- Remove id strings to quiet -Wunused-const-variable warnings from
GCC.
- While here, remove __FBSDID.
Reviewed by: brooks
Differential Revision: https://reviews.freebsd.org/D36830
When -B or -I are used, change() evaluates the lines in a hunk to
determine if it is a hunk that should be ignored. It does this by
reading each candidate line into a mallocated buffer via preadline()
and then calling ignoreline(). Previously the buffer was freed as a
side effect of ignoreline_pattern() called from ignoreline().
However, if only -B was specified, then ignoreline_pattern() was not
called and the lines were leaked. If both options were specified,
then ignoreline_pattern() was called before checking for a blank line
so that the second check was a use after free.
To fix, pull the free() out of ignoreline_pattern() and instead do it
up in change() so that is paired with preadline().
While here, simplify ignoreline() by checking for the -B and -I cases
individually without a separate clause for when both are set. Also,
do the cheaper check (-B) first, and remove a false comment (this
function is only called if at least one of -I or -B are specified).
Reviewed by: emaste
Reported by: GCC 12 -Wuse-after-free
Differential Revision: https://reviews.freebsd.org/D36822
The debug printf is intended to execute after the loop has ended to
log the selected file.
Reviewed by: imp, emaste
Reported by: GCC
Differential Revision: https://reviews.freebsd.org/D36815
As `ncpus` was otherwise unused, keeping track was pointless. Gets rid
of a warning from an unused variable.
Reviewed by: kib
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D36628
renice_abs_user and renice_rel_user tests modify global state, so they
are not compatible with parallel execution.
Reviewed by: asomers
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D36720
Mostly remove from the SEE ALSO section, adding a mention of the port
where not removed. Elsewhere, remove as appropriate and change from .Xr
to .Nm where a mention of telnetd continues to make sense (or removing
it would require significant reworking of the surrounding text).
Reviewed by: imp, delphij, emaste
Differential Revision: https://reviews.freebsd.org/D36785
Rack has had the ability to timeout connections that just sit idle automatically. This
feature of course is off by default and requires the user set it on (though the socket option
has been missing in tcp_usrreq.c). Lets get the progress timeout fully supported in
the base stack as well as rack.
Reviewed by: tuexen
Sponsored by: Netflix Inc
Differential Revision: https://reviews.freebsd.org/D36716
Improvements and changes to integrate bsddialog(1) with scripts in BASE.
Overview:
* New options. --and-widget, --keep-tite, --calendar.
* Change output format. Menus and --print-maxsize.
* Redefine sizing. Fixed rows, cols and menurows became at the most.
* Add DIAGNOSTICS. Error messages for bad arguments and options.
* Add keys. Space for --menu, fast keys for --msgbox and --yesno.
* Text. Change default text modification, add --cr-wrap.
See /usr/src/contrib/bsddialog/CHANGELOG '2022-09-24 Version 0.4'
for more detailed information.
Merge commit '9f24fda5a8e7ab8243e71473c7e2dc98b4877e64'
Long ago, ktr_tid was ktr_buffer which pointed to the buffer following
the header and was used internally in the kernel. Use was removed in
efbbbf570d and it was repurposed as ktr_kid in c6854c347f. For
ABI reasons, it stayed an intptr_t rather than becoming an lwpid_t at
the time. Since it doesn't hold a pointer any more (unless you have
a ktrace.out from 2005), change the type to long which is alwasy the
same size on all supported architectures. Add a suggestion to change
the type to lwpid_t (__int32_t) on a future ABI break.
Remove most remaining references to ktr_buffer, retaing a comment in
kdump.c explaining why negative values are treated as 0. While here,
accept that pid_t and lwpid_t are of type int and simplify casts in
printf.
This changed was motivated by CheriBSD where intptr_t is 16-bytes
in the pure-capability ABI.
Reviewed by: kib, markj
Sponsored by: DARPA, AFRL
Differential Revision: https://reviews.freebsd.org/D36599
It is some times hard to understand the difference between
kernel version and userland version. So clarify the -r option
of uname(1) in terms of a printed kernel version.
While here, add some cross references:
- cross reference freebsd-version(1) in uname(1)
- cross reference freebsd-version(1) and uname(1) in freebsd-update(8)
PR: 265594
Reported by: rwatson
Reviewed by: gbe, imp
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D36516
The ls(1) (with -l option) and find(1) (with -ls option) utilties
segment fault when operating on files with very large modification
times. A recent disk corruption set a spurious bit in the mtime
field of one of my files to 0x8000000630b0167 (576460753965089127)
which is in year 18,266,940,962. I discovered the problem when
running fsck_ffs(8) which uses ctime(3) to convert it to a readable
format. Ctime cannot fit the year into its four character field, so
returns ??? ??? ?? ??:??:?? ???? (typically Thu Nov 24 18:22:48 2021).
With the filesystem mounted, I used `ls -l' to see how it would
report the modification time and it segment faulted. The find(1)
program also segment faulted (see script below). Both these utilities
call the localtime(3) function to decode the modification time.
Localtime(3) returns a pointer to a struct tm (which breaks things
out into its component pieces: year, month, day, hour, minute,
second). The ls(1) and find(1) utilities then print out the date
based on the appropriate fields in the returned tm structure.
Although not documented in the localtime(3) manual page, localtime(3)
returns a NULL pointer if the passed in time translates to a year
that will not fit in an "int" (which if "int" is 32-bits cannot
hold the year 18,266,940,962). Since ls(1) and find(1) do not check
for a NULL struct tm * return from localtime(3), they segment fault
when they try to dereference it.
When localtime(3) returns NULL, the attached patches produce a date
string of "bad date val". This string is chosen because it has the
same number of characters (12) and white spaces (2) as the usual
date string, for example "Sep 3 22:06" or "May 15 2017".
The most recent ANSI standard for localtime(3) does say that localtime(3)
can return NULL (see https://pubs.opengroup.org/onlinepubs/9699919799/
and enter localtime in the search box). Our localtime(3) man page should
be updated to indicate that NULL is a possible return. More importantly,
there are over 100 uses of localtime(3) in the FreeBSD source tree (see
Differential Revision D36474 for the list). Most do not check for a NULL
return from localtime(3).
Reported by: Peter Holm
Reviewed by: kib, Chuck Silvers, Warner Losh
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D36474
New features overview:
* Unicode. User interface handles multi-column characters. API can
handle char* like a multibyte character string. Internally wide
characters are used for keyboard input, to adapt word wrapping and
dynamic text auto-sizing for multi-column characters.
* Forms refactoring. Complete rewrite deleting libformw dependency.
* Theme. New utility options to save and load custom theme at run-time.
* TUI navigation. Added keys to navigate input components. Changed
default focus behavior of input dialogs to be LGPL-dialog-like; a new
option can set the previous whiptail-like behavior.
See /usr/src/contrib/bsddialog/CHANGELOG '2022-08-29 Version 0.3'
for more detailed information.
Merge commit '2c9fd7655ba54e7239f528e1af9fe09662de9b03'
Instead of incrementing pretty random counters in the IP statistics,
create divert socket statistics structure. Export via netstat(1).
Differential revision: https://reviews.freebsd.org/D36381
The divert(4) is not a protocol of IPv4. It is a socket to
intercept packets from ipfw(4) to userland and re-inject them
back. It can divert and re-inject IPv4 and IPv6 packets today,
but potentially it is not limited to these two protocols. The
IPPROTO_DIVERT does not belong to known IP protocols, it
doesn't even fit into u_char. I guess, the implementation of
divert(4) was done the way it is done basically because it was
easier to do it this way, back when protocols for sockets were
intertwined with IP protocols and domains were statically
compiled in.
Moving divert(4) out of inetsw accomplished two important things:
1) IPDIVERT is getting much closer to be not dependent on INET.
This will be finalized in following changes.
2) Now divert socket no longer aliases with raw IPv4 socket.
Domain/proto selection code won't need a hack for SOCK_RAW and
multiple entries in inetsw implementing different flavors of
raw socket can merge into one without requirement of raw IPv4
being the last member of dom_protosw.
Differential revision: https://reviews.freebsd.org/D36379
The target modifiers (-g, -p, -u) may occur in any position except
between -n and its argument; furthermore, we support both the old
absolute form (without -n) and the modern relative form (with -n).
Sponsored by: Klara, Inc.
Replace the quoted printable code with one that respects RFC2045
Add tests about this parsers and encoders, using examples from the
wikipedia page.
Reviewed by: pstef
Differential Revision: https://reviews.freebsd.org/D36314
The minigzip(1) was initially introduced as a minimal replacement
of GNU gzip(1). We have replaced the GNU gzip(1) with the zlib
based, GPL-free implementation, and minigzip(1) is not being used
anywhere in the base system, so just remove it.
Relnotes: yes
Reviewed by: emaste
Differential Revision: https://reviews.freebsd.org/D35979
If the -c flag is used, then we can set it with ICONV_SET_DISCARD_ILSEQ;
otherwise, leave it alone. The user may have specified //IGNORE in the
'to' codeset specification, there's no reason we can't allow that but
we'll currently turn it off.
Reviewed by: thj
Sponsored by: Klara, Inc.
Differential Revision: https://reviews.freebsd.org/D34342
- new sentence, new line
- unknown AT&T UNIX version: At v7
- no blank before trailing delimiter
- reference the ASCII(8) manual page
MFC after: 5 days
The single line comment indicator '//' is only detected at the
beginning of a line or when following white space to allow URLs
in calendar entries.
MFC after: 3 days
Given the way bmake/unit-tests is visited, when doing 'test'
MK_AUTO_OBJ=yes will not be effective.
So create the objdir before running the sub-make.
Also ensure MAKEOBJDIR is passed to opt-m-include-dir
Reviewed by: deo
nl actually first was available with System III, not System Vr2. Updated
based on discussion on TUHS mailing list (archive recently moved so this
message isn't get available in the archive).
Suggested by: segalogo (Matt G)
Commit e7fd9688ea changed vtfontcvt's command line parsing, but did
not correctly update the usage (it omitted the new -o flag).
Fixes: e7fd9688ea ("Move font related data structured to...")
MFC after: 1 week
Sponsored by: The FreeBSD Foundation
Replace struct timeval in header with struct timespec.
To differentiate header formats, add a new KTR_VERSIONED flag
set in the header type field similar to the existing KTRDROP flag.
To make it easier to extend ktrace headers in the future,
extend the existing header with a version field (version 0 is
reserved for older records without KTR_VERSIONED) as well as
new fields holding the thread ID and CPU ID.
Reviewed by: jhb, pauamma
Differential Revision: https://reviews.freebsd.org/D35774
MFC after: 2 weeks
The reason is that in order to protect a process procctl(2) needs
the PRIV_VM_MADV_PROTECT privilege, which is currently denied in jails
(see kern_jail.c).
MFC after: 1 week
This allows for easy copy-and-paste of a unix(4) peer name for lookup.
With current implementation it is guaranteed that a peer listed could be
found in the output.
Differential revision: https://reviews.freebsd.org/D35727
Kernel provides us with enough information to display all possible
connections between UNIX sockets.
o Store unp_conn, xu_firstref and xu_nextref in the faddr of a UNIX sock.
o Build tree of file descriptors, indexed by the socket pointer.
o In displaysock() print out all possible information:
1) if socket is bound, print name of this socket
2) if socket has connected to a peer with a name, print peers name
3) if socket has connected to a peer without a name, print [pid fd]
4) if a bound socket has received connections, print list of them
as [pid fd]
Previously, only 1) either 2) were printed.
Reviewed by: tuexen
Differential revision: https://reviews.freebsd.org/D35726
Three digit file descriptors are very common these days. So let the
columns not break with them.
Reviewed by: tuexen
Differential revision: https://reviews.freebsd.org/D35725
o Use tree to lookup by socket kvaddr. The size of hash is too big for a
small virtual machine and at the same time too little for a large
production server. A tree would better fit here.
o For those pcbs, that don't have a socket associated, use a list.
o Provide a second tree to lookup by pcb kvaddr. These removes full hash
traversal when printing every unix(4) socket.
Reviewed by: tuexen
Differential revision: https://reviews.freebsd.org/D35724
The field for interface names for netstat -i was 5 characters by
default, which is no longer sufficient with names like "vlan1234"
and "vtnet0". netstat -iW computed the necessary field width, but
also enlarged the address field by a lot (especially with IPv6 enabled).
Make netstat -i compute the field width for interface names with or
without -W. Note that the existing default output does not fit in
80 columns in any case. Update the man page accordingly, documenting
the remaining effect of -W with -i. Also add -W to the list of
General Options, as there are numerous pointers to this.
Reported by: Chris Ross
Reviewed by: melifaro, rgrimes, cy
Differential Revision: https://reviews.freebsd.org/D35703
MFC after: 1 week
If the line with replacement cannot be constructed xargs should
terminate as documented in the man page
We encounter this error, but gnu/xargs doesn't because they have a much
larger limit for created outputs (~10000 lines).
Reviewed by: oshogbo
Sponsored by: Klara, Inc.
Differential Revision: https://reviews.freebsd.org/D35574
This avoids the need for dealing with converting lwpinfo for alternate
ABIs in gcore itself.
Reviewed by: markj
MFC after: 2 weeks
Sponsored by: DARPA
Differential Revision: https://reviews.freebsd.org/D35667