Commit graph

14900 commits

Author SHA1 Message Date
Mark Johnston
946a297fbd sort: Fix random sort
bwsrawdata() is supposed to return the string buffer.

PR:		259451
Reported by:	sigsys@gmail.com
Fixes:		d053fb22f6 ("usr.bin/sort: Avoid UBSan errors")
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit e9bfb50d5e)
2021-11-01 09:10:54 -04:00
Michael Reifenberger
59821002f7 systat: Handle SIGWINCH to properly window resizing and adjust -swap disk stat based on new size.
(cherry picked from commit 6648383803)
2021-11-01 03:26:53 +02:00
Konstantin Belousov
f33a9999e2 Augment systat(1) -swap to display large swap space processes
(cherry picked from commit 57e5da2c98)
2021-11-01 02:44:51 +02:00
Konstantin Belousov
7a3d7b9efc ldd: do not use dlopen(RTLD_TRACE) for dso when format is specified
PR:	259069

(cherry picked from commit 2c7a6dad4d)
2021-10-28 03:35:54 +03:00
Konstantin Belousov
d53274be0d ldd: style
(cherry picked from commit ca8c576d10)
2021-10-28 03:35:54 +03:00
Ed Maste
7a78903113 lorder: process read-only data symbols
Previously they were skipped.  lorder(1) serves no functional purpose
today but we might as well address this longstanding bug while it is
still in the tree.

PR:		133860
MFC after:	1 week
Submitted by:	John Hein

(cherry picked from commit e1d6d6f924)
2021-10-24 20:37:05 -04:00
Mateusz Piotrowski
c1c3ef8ef8 timeout.1: Fix typos in examples
MFC after:	3 days

(cherry picked from commit 12615938c6)
2021-10-24 18:33:37 +02:00
Kyle Evans
b6aec78847 cmp: initialize limit to avoid stack garbage limits
Pointy hat:	kevans
Fixes:	4e380e8474 ("cmp: add -n, --bytes to limit number of bytes [...]")
Sponsored by:	Klara, Inc.

(cherry picked from commit f1f7f31366)
2021-10-23 14:01:00 -05:00
Yoshihiro Takahashi
3bfe213143 unzip: Fix segmentation fault if a zip file contains buggy filename.
PR:             259011
Reported by:    Robert Morris
Submitted by:   ak

(cherry picked from commit 2c614481fd)
2021-10-18 20:16:02 +09:00
Stefan Eßer
e84a97439b usr.bin/gh-bc, contrib/bc: update to version 5.0.0
Merge commit 2f57ecae4b

This is a new major release with a number of changes and extensions:

- Limited the number of temporary numbers and made the space for them
  static so that allocating more space for them cannot fail.
- Allowed integers with non-zero scale to be used with power, places,
  and shift operators.
- Added greatest common divisor and least common multiple to lib2.bc.
- Made bc and dc UTF-8 capable.
- Added the ability for users to have bc and dc quit on SIGINT.
- Added the ability for users to disable prompt and TTY mode by
  environment variables.
- Added the ability for users to redefine keywords.
- Added dc's modular exponentiation and divmod to bc.
- Added the ability to assign strings to variables and array elements
  and pass them to functions in bc.
- Added dc's asciify command and stream printing to bc.
- Added bitwise and, or, xor, left shift, right shift, reverse,
  left rotate, right rotate, and mod functions to lib2.bc.
- Added the functions s2u(x) and s2un(x,n), to lib2.bc.

MFC after:	1 week

(cherry picked from commit 44d4804d19)

vendor/bc: update to upstream version 5.0.2

(cherry picked from commit a60ef1802a)
(cherry picked from commit 662087dfd0)

contrib/bc: remove files ommitted from the release

A number of files have been removed from the release distribution of
this bc implementation. They were mostly relevant for pre release
testing and benchmarking to identify regressions. The Markdown
sources of the man pages are only relevant for combinations of build
options not used in FreeBSD and need non-default conversion tools
(available as ports in FreeBSD).

All the omitted files can be found in the upstream git repository,
and they are fetched when building this software as a port. But they
have never been used in the FreeBSD base system.

(cherry picked from commit ea31d1a5c4)

Remove files that were checked in with wrong .gitattributes

These files will be added back in updated form, but are only relevant
for the Windows platform, anyway.

(cherry picked from commit d6c323eda2)

contrib/bc: merge version 5.1.0 from vendor branch

This version adds options and functions that allow to print numbers
in the open interval (-1 .. 1) with or without a leading 0 digit.

Additionally, an option has been added to prevent line wrap and
allows to print arbitrarily long results on a single line.

Merge commit '5d58a51571721190681c50d4bd3a1f45e6282d72'

(cherry picked from commit d43fa8ef53)

contrib/bc: update to version 5.1.1

Merge commit '6f49f5cdde1c62c4e5a743e895f3afe592b5c0e5'

(cherry picked from commit a30efc5ca7)

contrib/bc: temporarily disconnect the tests for 5.0.2

The tests that come with version 5.0.2 have been extended to cover the
line editing functions. It has been found that these tests generate
false negative results in FreeBSD, most likely due to an issue in the
pexpect functionality used.

These history tests are skipped on systems that do not have python and
py-pexpect installed (and thus are unlikely to cause CI test failures),
but in order to not cause irritating failures on systems were these
packages are in fact installed, I temporarily disconnect them.

I had planned to skip this version due to the issue with the history
tests, but some committer has asked me to go ahead since the currently
used version 5.0.0 contains a macro name that collides with a project
he is working on.

No MFC of this version is planned. A version 5.0.3 is expected to be
released soon, and that version will allow to reconnect the tests and
will be MFCed.

(cherry picked from commit f774652b0e)

Add back Windows only VCXProj files

(cherry picked from commit ded0d3d486)

contrib/bc: re-enable tests after the import of version 5.1.0

The tests have been fixed to not write any data outside of the
temporary work directory provided by the test framework.

MFC after:	3 days

(cherry picked from commit b8d895faf4)

Revert erroneous commit ded0d3d486

These files came from a prior commit to contrib/bc and seem to have
been placed in the top of the source tree by a failed git rebase.

Reported by:	markj

(cherry picked from commit f902ca97bd)
2021-10-12 16:18:26 +02:00
Jessica Clarke
2bfc7f7b75 llvm-objcopy: Install llvm-strip link
Just as elftoolchain's objcopy doubles as strip, so does LLVM's. Note
that we do not currently have a committed copy of the manpage generated
from the rST source so no manpage is installed for llvm-strip.

(Note this is only a partial MFC, as WITH_LLVM_BINUTILS was not MFC'ed)

Reported by:	Shawn Webb <shawn.webb@hardenedbsd.org>
Tested by:	Shawn Webb <shawn.webb@hardenedbsd.org>
MFC after:	1 week

(cherry picked from commit f28c1d0c5c)
2021-10-10 14:34:33 +01:00
Kyle Evans
c8d19408fe login: use sizeof(audit_cond) consistently, NFC
The other three instances were already converted to use audit_cond, this
one was just changed from sizeof(long) -> sizeof(int).

(cherry picked from commit 7f4bb50176)
2021-10-08 19:56:53 -05:00
Ed Maste
d71103026d ar: provide error exit status upon failure
Previously ar and ranlib returned with exit status 0 (success) in the
case of a missing file or other error.  Update to use error handling
similar to that added by ELF Tool Chain after that project forked
FreeBSD's ar.

PR:		PR257599 [exp-run]
Reported by:	Shawn Webb, gehmehgeh (on HardenedBSD IRC)
Reviewed by:	markj
Obtained from:	elftoolchain
MFC after:	2 months
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D31402

(cherry picked from commit 38911b3c2c)
2021-10-08 20:28:31 -04:00
Kyle Evans
6a1ef178d8 cmp: add -b, --print-bytes
This is compatible with GNU cmp.

Reviewed by:	bapt, markj (earlier version)
Sponsored by:	Klara, Inc.

(cherry picked from commit f66b9b40f4)
2021-10-03 00:15:12 -05:00
Kyle Evans
0ab72f80ab cmp: add -i, --ignore-initial, an alternative to skip1/skip2 args
This is compatible with GNU cmp.

Reviewed by:	markj
Sponsored by:	Klara, Inc.

(cherry picked from commit 8d546b6832)
2021-10-03 00:15:08 -05:00
Kyle Evans
1159a71ad7 cmp: add -n, --bytes to limit number of bytes to compare
This is compatible with GNU cmp.

Reviewed by:	markj
Sponsored by:	Klara, Inc.

(cherry picked from commit 4e380e8474)
2021-10-03 00:15:05 -05:00
Kyle Evans
5d3ac4ddf9 cmp: accept SI suffixes for skip1 and skip2
This is compatible with GNU cmp.

Reviewed by:	bapt (earlier version), markj, imp
Sponsored by:	Klara, Inc.

(cherry picked from commit f6787614fd)
2021-10-03 00:15:01 -05:00
Kyle Evans
0760a2e9a4 man: reset OPTIND before parsing args
From jilles: POSIX requires that a script set `OPTIND=1` before using
different sets of parameters with `getopts`, or the results will be
unspecified.

The specific problem observed here is that we would execute `man -f` or
`man -k` without cleaning up state from man_parse_args()' `getopts`
loop.  FreeBSD's /bin/sh seems to reset OPTIND to 1 after we hit the
second getopts loop, rendering the following shift harmless; other
/bin/sh implementations will leave it at what we came into the loop at
(e.g., bash as /bin/sh), shifting off any keywords that we had.

Input from:	jilles
Reviewed by:	allanjude, bapt, imp
Sponsored by:	Klara, Inc.

(cherry picked from commit f555b39e6b)
2021-10-03 00:14:43 -05:00
Yoshihiro Takahashi
cea130c0b8 unzip: sync with NetBSD upstream to add passphrase support
- Add support for password protected zip archives.
  We use memset_s() rather than explicit_bzero() for more portable
  (See PR).
- Use success/failure macro in exit()
- Mention ZIPX format in unzip(1)

Submitted by:	Mingye Wang and Alex Kozlov (ak@)
PR:		244181
Reviewed by:	mizhka
Obtained from:	NetBSD
Differential Revision:	https://reviews.freebsd.org/D28892

(cherry picked from commit a4724ff481)
2021-10-02 20:56:19 +09:00
Piotr Pawel Stefaniak
a8446d4124 diff3: document and test -T
(cherry picked from commit 9f7a81b133)
2021-09-25 10:34:39 +02:00
Piotr Pawel Stefaniak
dbabfd7e26 diff3: implement --strip-trailing-cr
(cherry picked from commit 54a3415cb6)
2021-09-25 10:34:39 +02:00
Piotr Pawel Stefaniak
000d03450b diff3.1: update manual page to match code
(cherry picked from commit e8ff95356c)
2021-09-25 10:34:39 +02:00
Piotr Pawel Stefaniak
216bf478e2 diff3: improve style
(cherry picked from commit 702dda4368)
2021-09-25 10:34:39 +02:00
Piotr Pawel Stefaniak
4bfbc5fbc9 diff3: sync with upstream
* replace realloc calls with reallocarray calls
 * fix merging of files that lack newlines

Obtained from:	OpenBSD

(cherry picked from commit 7f7b03f389)
2021-09-25 10:34:39 +02:00
Piotr Pawel Stefaniak
bda949b6ef diff: read whole files to determine if they are ASCII text
Before this change, only the first BUFSIZE bytes were checked.

(cherry picked from commit 3cbf98e2be)
2021-09-25 10:34:39 +02:00
Piotr Pawel Stefaniak
ece58f7ada diff: don't output carriage returns that were stripped on input
--strip-trailing-cr worked as intended for comparison between files,
but the characters were still present in final output.

(cherry picked from commit af2f016431)
2021-09-25 10:34:38 +02:00
Konstantin Belousov
492a76bcd6 proccontrol(1): Add wxmap control
(cherry picked from commit ac8af19380)
2021-09-24 03:26:59 +03:00
Konstantin Belousov
9ebc7d49be Style
(cherry picked from commit 1349891a0e)
2021-09-24 03:26:59 +03:00
Edward Tomasz Napierala
4256412900 proccontrol(1): implement 'nonewprivs'
(cherry picked from commit acb1f1269c)
2021-09-24 03:26:59 +03:00
Mariusz Zaborski
c91cdb006e grep: fix combination of quiet and count flag
When the quiet (-q) flag is provided, we don't expect any output.
Currently, the behavior is broken:
$ grep -cq flag util.c
1

$ grep -cs flag util.c
55

First of all, we print a number to stdout. Secondly, it just returns
0 or 1 (which is unexpected). GNU grep with c and q flags doesn't
print anything.

Reviewed by:	markj
Differential Revision:	https://reviews.freebsd.org/D31108

(cherry picked from commit 24c681a7f6)
2021-09-22 10:05:39 -04:00
Baptiste Daroussin
1e5c3ce7a5 import nvi 2.2.0-3bbdfe4
(cherry picked from commit 6680e5a52f)
2021-09-22 12:07:48 +02:00
Kevin Bowling
d44b684e1a calendar.freebsd: Fix off-by-one error
(cherry picked from commit 007c2463d6)
2021-09-17 16:08:18 -07:00
John Grafton
3e3f48e6c4 top(1): indicate how to reset grep string
Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/536/files

(cherry picked from commit 4ccbbe5f06)
2021-09-12 19:12:01 -06:00
John Grafton
72f20536ea top(1): support command name and argument grepping
Obtained from:  OpenBSD
Reviewed by:	imp@
Pull Request:	https://github.com/freebsd/freebsd-src/pull/479

(cherry picked from commit a00d703f2f)
2021-09-12 19:12:00 -06:00
Jessica Clarke
523f2486d5 clang: Support building with GCC and DEBUG_FILES disabled
If MK_DEBUG_FILES=no then the Clang link rule has clang as .TARGET,
rather than clang.full, causing the implicit ${CFLAGS.${.TARGET:T}} to
be CFLAGS.clang, and thus pull in flags intended for when your compiler
is Clang, not when linking Clang itself. This doesn't matter if your
compiler is in fact Clang, but it breaks using GCC as, for example,
bsd.sys.mk adds -Qunused-arguments to CFLAGS.clang. This is seen when
trying to build a bootstrap toolchain on Linux where GCC is the system
compiler.

Thus, introduce a new internal NO_TARGET_FLAGS variable that is set by
Clang to disable the addition of these implicit flags. This is a bigger
hammer than necessary, as flags for .o files would be safe, but that is
not needed for Clang.

Note that the same problem does not arise for LDFLAGS when building LLD
with BFD, since our build produces a program called ld.lld, not plain
lld (unlike upstream, where ld.lld is a symlink to lld so they can
support multiple different flavours in one binary).

Suggested by:	sjg
Fixes:		31ba4ce889 ("Allow bootstrapping llvm-tblgen on macOS and Linux")
MFC after:	1 week
Reviewed by:	dim, imp, emaste
Differential Revision:	https://reviews.freebsd.org/D31532

(cherry picked from commit c8edd05426)
2021-09-07 13:08:19 +01:00
Konstantin Belousov
d5d99c1c07 ldd: Remove non-functional -v option
(cherry picked from commit 17fc43bc01)
2021-09-03 04:08:35 +03:00
Gordon Bergling
dbb74dd891 Fix some common typos in source code comments
- s/priviledged/privileged/
- s/funtion/function/
- s/doens't/doesn't/
- s/sychronization/synchronization/

(cherry picked from commit 5bdf58e196)
2021-08-31 08:13:15 +02:00
Gordon Bergling
08fe2da3ce nfsstat(1): Fix a typo in an error message
- s/priviledged/privileged/

(cherry picked from commit 72a92f91f4)
2021-08-30 07:44:57 +02:00
Olivier Cochard
108633bb15 diff: Use unprivileged_user with report_identical test
Approved by:	bapt
Sponsored by:	Netflix
Differential Revision:	https://reviews.freebsd.org/D28466

(cherry picked from commit b67df8d7c2)
2021-08-22 18:48:55 +02:00
Mark Johnston
4c6246b76e tail: Add regression tests for -f and -F
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit 58b1a126b9)
2021-08-21 12:18:21 -04:00
Mark Johnston
9bfe19ff82 tail: Fix -f with stdin
Based on a patch from swills@.

(cherry picked from commit 7e11889959)
2021-08-21 12:18:17 -04:00
Gordon Bergling
ac7cf0c636 Fix a few typos in source code comments
- s/procesing/processing/

(cherry picked from commit 288e553623)
2021-08-19 09:27:34 +02:00
Ed Maste
d1d9ee6f78 ar: remove invalid extra param in bsdar_warnc calls
A number of warnings passed an exit status code to bsdar_warnc, but it
does not take exit status (as a warning, it does not exit).

MFC after:	1 week
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit 09319f7d3f)
2021-08-17 21:27:41 -04:00
Mateusz Piotrowski
5a1da25da2 grep: Fix an incorrect description of the -C flag
It seems that the number of lines is no longer an optional parameter to
the -C flag. Document it accordingly both in the manual page and the
usage message.

Reviewed by:	yuripv
Approved by:	yuripv
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D28509

(cherry picked from commit be6b8b7a3a)
2021-08-15 23:01:01 +02:00
Gordon Bergling
375a52cc3c mkimg(1): Correct a typo in the usage output
- s/partion/partition/

(cherry picked from commit 6bddade611)
2021-08-14 08:28:00 +02:00
Alex Richardson
c65dab7dd2 Allow bootstrapping llvm-tblgen on macOS and Linux
This is needed in order to build various LLVM binutils (e.g. addr2line)
as well as clang/lld/lldb.

Co-authored-by: Jessica Clarke <jrtc27@FreeBSD.org>
Test Plan:	Compiles on ubuntu 18.04 and macOS 11.4
Reviewed By:	dim
Differential Revision: https://reviews.freebsd.org/D31057

(cherry picked from commit 31ba4ce889)
2021-08-05 10:01:08 +01:00
Alex Richardson
1d7c196d11 Remove mkcsmapper_static and mkesdb_static from build-tools
Build them as part of the bootstrap-tools phase instead.

Reviewed by:	emaste (no objections)
Differential Revision: https://reviews.freebsd.org/D28181

(cherry picked from commit 2de949cf85)
2021-08-05 10:00:56 +01:00
Alex Richardson
7a7324d9ce usr.bin/diff: fix UBSan error in readhash
UBSan complains about the `sum = sum * 127 + chrtran(t);` line below since
that can overflow an `int`. Use `unsigned int` instead to ensure that
overflow is well-defined.

Reviewed By:	imp
MFC after:	1 week
Differential Revision: https://reviews.freebsd.org/D31075

(cherry picked from commit c78f449d85)
2021-08-05 09:59:26 +01:00
Alex Richardson
608cb96312 usr.bin/login: send errors to console if syslog isn't running
I was debugging why login(1) wasn't working as expected on a minimal
MFS_ROOT disk image. This image doesn't have syslogd running so the
warnings were lost and I had to use GDB to find out why login(1) was
failing (missing PAM libraries) instead of being able to see it in
the console output.

MFC after:	1 week
Reviewed By:	pfg
Differential Revision: https://reviews.freebsd.org/D30892

(cherry picked from commit 4d552825ec)
2021-08-05 09:57:54 +01:00
Alex Richardson
e4c2ffe932 usr.bin/sort: Avoid UBSan errors
UBSan complains about out-of-bounds accesses for zero-length arrays. To
avoid this we can use flexible array members. However, the C standard does
not allow for structures that only contain flexible array members, so we
move the length parameters into that structure too.

Split out from D28233.

Reviewed By:	markj
MFC after:	1 week
Differential Revision: https://reviews.freebsd.org/D31009

(cherry picked from commit d053fb22f6)
2021-08-05 09:57:45 +01:00