Commit Graph
31921 Commits
Author SHA1 Message Date
Pádraig Brady 9bd1c7bb53 build: update to latest gnulib
* gnulib: Update to latest, mainly to get strftime fixes.
2026-10-30 16:41:54 +00:00
Pádraig Brady 2a078e45fa tests: printf: avoid false failure with dash
* tests/printf/printf.sh: Use printf rather than echo,
as echo unconditionally interprets backslashes in dash.
2026-10-30 14:50:17 +00:00
Pádraig Brady b4728bfa9b tests: timeout: fix false failure on some shells
The fix in commit v9.12-166-gb6b06854f was incomplete.
This is now tested to pass with SHELL=/bin/dash on Debian 10
(which otherwise defaults to bash even though /bin/sh is dash).

* tests/timeout/timeout.sh: Ensure the waiting shell's stderr
is not redirected to the full pipe, so any "Killed" message
does not block things.
2026-10-30 14:36:49 +00:00
Collin Funk d58314f178 pr: fix a crash when reading more than INT_MAX bytes for a single page
* src/pr.c (buff_current): Define as an idx_t instead of an int.
(line_vector): Define as an array of idx_t elements instead of int.
(store_colum): Define a variable used to set buff_current as an idx_t.
* NEWS: Mention the bug fix.

Discovered by Anthropic's OSS Scanner, as bug ANT-2026-C1YW9FO0.
2026-10-29 16:29:14 -07:00
Collin Funk 56531e52a3 dd: don't place a hole when seeking N bytes when N is less than obs
* src/dd.c (main): Also account for seeking bytes in a few conditions.
* tests/dd/bytes.sh: Add a test case.
* tests/dd/fail-ftruncate-fstat.sh (fail_ftruncate_fstat): New function.
Use it to test seeking on bytes, and make sure fstat and ftruncate are
called.
* NEWS: Mention the bug fix.

Discovered by Anthropic's OSS Scanner, as bug ANT-2026-NLK8TXH1.
2026-10-29 16:23:47 -07:00
Mohammadreza Khellat 5ba56b6925 doc: fix garbled line count in TODO sort notes
The sortlines algorithm note listed the test corpus as "426,4424 lines".
That looks like a mistyped thousands grouping; use 4,264,424 instead
(consistent with ~33b/line for the stated 140,213,394-byte GCC tree).

Link: https://github.com/coreutils/coreutils/pull/401
2026-10-29 16:17:49 +00:00
Pádraig Brady b6b06854f3 tests: timeout: avoid false failure on some shells
dash in all modes, or bash when not invoked in posix mode
will issue a "Terminated" message and thus block with our filled pipe,
and not fire the trap.  I.e. with sh -> dash this test failed,
and sh -> bash this test passed (as bash is in POSIX mode in that case).
Interestingly this shows the shells have much the same problem
with stderr diagnostic side effects that timeout now avoids.

* tests/timeout/timeout.sh: Redirect the shell's stderr to /dev/null
so we don't care whether it outputs "Terminated" or not.  Also change
all "sh -c" to "$SHELL -c" for better consistency across all tests.
2026-10-29 14:51:21 +00:00
Collin Funk 7a3fdd3185 cp,mv: print the destination file name when setting xattrs fails
* src/copy.c (copy_attr_quote): Return a xstrdup'd copy of the result of
quoteaf, so that slot 0 of quotearg can be overwritten by a subsequent
call without overwriting the previously quoted string.
(copy_attr_free): Free the string. Remove MAYBE_UNUSED from the string.
* tests/cp/xattr.sh: Add a getlimits_ and uses_strace_ invocation.
(block_setxattr): New function. Use it to check the error/warning
message when setting extended attributes on the destination fails.
* NEWS: Mention the bug fix.

Discovered by Anthropic's OSS Scanner, as bug ANT-2026-BPGHOHDX.
2026-10-27 23:25:59 -07:00
Collin Funk 7dc6f9c0d8 install: use the user's umask when invoking 'strip'
* src/install.c (initial_umask): New variable.
(strip): Set the umask to initial_umask before invoking 'strip' and then
reset it to zero after the child is created.
(main): Save the initial umask when setting it to zero.
* tests/install/strip-program.sh: Add a few invocations to test the
behavior.
* NEWS: Mention the bug fix.

Discovered by Anthropic's OSS Scanner, as bug ANT-2026-39LQ2UOD.
2026-10-27 20:35:10 -07:00
Collin Funk 9e804edddb printf: quote the ignored characters in the warning
* src/printf.c (STRTOX): Add a call to quote when printing the ignored
characters.
* tests/printf/printf.sh: Adjust an existing test case. Add another
quoting test case.

Discovered by Anthropic's OSS Scanner, as bug ANT-2026-I9I24ON7.
2026-10-27 18:16:03 -07:00
Collin Funk c242899118 nl: don't treat empty lines as headers with an empty -d argument
* src/nl.c (check_section): Add a check for a zero section delimiter
length.
* tests/nl/nl.sh: Add a test case.
* NEWS: Mention the bug fix.

Discovered by Anthropic's OSS Scanner, as bug ANT-2026-PDYYNTYZ.
2026-10-27 18:16:03 -07:00
Pádraig Brady 266abf3fd2 cksum: fix --check ambiguities in base64 detection
* src/cksum (valid_digits): Use '=' to disambiguate hex and base64.
(split_3): Likewise.
(digest_check): Likewise.
* tests/cksum/cksum-base64-untagged.sh: Add a test case.
* NEWS: Mention the fix.
2026-10-27 23:15:56 +00:00
Pádraig Brady 119cabc8a1 cksum: support mixed reversed format checksum files
* src/cksum.c (digest_check): Reset the detection flag per file.
* tests/cksum/cksum-c.sh: Add a test case.
* tests/cksum/md5sum-bsd.sh: Likwise.
* NEWS: Mention the fix.
2026-10-27 23:15:56 +00:00
Pádraig Brady 1ca499910a cksum: fix incorrectly accepting lengths on fixed length algorithms
* src/cksum.c (split_3): Restrict to length variable digest types.
* tests/cksum/cksum-c.sh: Add test cases.
* NEWS: Mention the fix.

Discovered by Anthropic's OSS Scanner, as bug ANT-2026-ATAXIQDM.
2026-10-27 23:15:56 +00:00
Pádraig Brady 9f49862b99 cksum: fix -a sha2 --check handling of mixed length checksums
It's not a usual case, but for consistency "-a sha2" should support
e.g. untagged checksums that are a mix of sha256sum and sha512sum.

* src/cksum.c (split_3): Reset the sha2 variant search if
the generic sha2 is specified.  It's ok to reset the global
CKSUM_ALGORITHM as its subsequent use is conflicting with
the specific chosen variant.
* tests/cksum/cksum-c.sh: Add test cases.
* NEWS: Mention the bug fix.

Discovered by Anthropic's OSS Scanner, as bug ANT-2026-83HIODH2.
Discovered by SecBuddyF (with Hy4-preview) of Tencent KeenSecurityLab.
2026-10-27 23:15:56 +00:00
Pádraig Brady 46776b5e80 timeout: fix handling of --signal=CHLD and --signal=ALRM
These signals are used by timeout(1) itself, so need special handling.
Since commit v8.13-11-g80a1aca0d we incorrectly ignored them,
which was exacerbated by commit v8.26-39-g2f69dba5d which caused
the -sCHLD case to hang upon child exit.

* src/timeout.c (send_sig): Don't ignore SIGHLD, and discard
the self sent SIGALRM, and rearm the handler.
* tests/timeout/timeout.sh: Add test cases.
* NEWS: Mention the fixes.

Discovered by Anthropic's OSS Scanner, as bug ANT-2026-2EQL2L05.
2026-10-27 23:15:30 +00:00
Pádraig Brady 90843a2dc9 timeout: ensure we can --kill-after with blocked --verbose output
* NEWS: Adjust to mention that -k without -f is resilient to blocking.
* src/timeout.c (cleanup): Unblock SIGALRM when diagnosing, so
an armed --kill-after is honored.
* tests/timeout/timeout.sh: Add a test case.

Discovered by Anthropic's OSS Scanner, as bug ANT-2026-GV4Z4T3T.
2026-10-27 23:15:30 +00:00
Pádraig Brady 8fcaebfe47 timeout: ensure we timeout with --verbose failures
In the edge case where --verbose diagnostics might block
or induce signals, ensure we always timeout the monitored command
and do not loop diagnosing diagnostic induced signals.

* NEWS: Mention the bug fix.
* src/timeout.c (cleanup): Avoid diagnosing SIGPIPE and SIGXFSZ.
Also send the signal before diagnosing to ensure command is timed out.
* tests/env/env-signal-handler.sh: Run timeout(1) with -f to ensure
the SIGKILL is diagnosed.
* tests/timeout/timeout.sh: Likewise.  Also add test cases for
SIGPIPE and SIGXFSZ.

Discovered by Anthropic's OSS Scanner, as bug ANT-2026-GV4Z4T3T.
2026-10-27 23:15:30 +00:00
Sylvestre Ledru 074eb270fe tests: split: check the -l count is a plain decimal number
* tests/split/lines.sh: Ensure a leading zero in -l or the obsolete
-N form is not read as octal, that a leading '+' or blank is accepted,
and that size suffixes and hex are rejected.
https://github.com/uutils/coreutils/pull/15678

Link: https://github.com/coreutils/coreutils/pull/400
2026-10-27 20:54:14 +00:00
Pádraig Brady 98731a220f doc: mention coreutils-security@gnu.org
* README: List the corresponding email address on the first
line of each sections.
Note README is shown on the github project front page.
* .github/ISSUE_TEMPLATE.txt: Adjust similarly.
* .github/PULL_REQUEST_TEMPLATE.txt: Likewise.
2026-10-27 20:29:42 +00:00
Collin Funk a514201deb od: improve overflow detection and fix a crash when used on /dev/zero
* src/od.c (format_address_std): Add an affirm call to check that the
address is positive or equal to zero, which would have caused a
descriptive assertion in this case instead of a SIGSEGV.
(offset_add): New function.
(dump): Use it to diagnose overflows.
(dump_strings): Likewise.
* NEWS: Mention the bug fix.

Discovered by Anthropic's OSS Scanner, as bug ANT-2026-EZXPB4TK.
2026-10-26 18:01:52 -07:00
Collin Funk 5471637563 getlimits: print the limits for 'unsigned short'
* src/getlimits.c (USHRT_MIN): New macro.
(main): Print the limits for 'unsigned short'.
2026-10-25 17:20:53 -07:00
Collin Funk 7d74e197bb cp: quote directory names when --parents and --verbose are used
* src/cp.c (make_dir_parents_private): Quote the names of the directory
and the source.
* tests/cp/verbose-parents-quote.sh: New file
* tests/local.mk (all_tests): Add the new test.
* NEWS: Mention the bug.

Discovered by Anthropic's OSS Scanner, as bug ANT-2026-JJG3V3T9.
2026-10-25 14:32:32 -07:00
Collin Funk 074be5fae5 chown,chgrp: don't print uninitialized ownership info on dangling links
* src/chown-core.c (change_file_owner): Set the pointer to NULL if
fstatat fails.
* tests/chgrp/verbose-dangling-symlink.sh: New file.
* tests/chown/verbose-dangling-symlink.sh: New file.
* tests/local.mk (all_tests): Add the new tests.
* NEWS: Mention the bug fix.

Discovered by Anthropic's OSS Scanner, as bug ANT-2026-YYGC42VE.
2026-10-25 14:32:32 -07:00
Sylvestre Ledru fdca506d98 tests: sort: check -t given twice must be the same separator
* tests/sort/sort.pl (tab-dup1, tab-dup2, tab-incompat1)
(tab-incompat2, tab-incompat3): New tests.  Ensure differing -t
separators, including NUL, evoke "incompatible tabs", while
repeating the same one is accepted.
https://github.com/uutils/coreutils/pull/15707

Link: https://github.com/coreutils/coreutils/pull/399
2026-10-25 13:43:21 +00:00
Sylvestre Ledru af626a5749 tests: cp: check -rT does not copy through a symlinked destination
* tests/cp/r-T-symlink.sh: New test.  Ensure cp -rT refuses to copy
a directory over a symlink to a directory, while a trailing slash or
omitting -T copies into what the symlink resolves to.
* tests/local.mk (all_tests): Reference the new test.
https://github.com/uutils/coreutils/pull/14993

Link: https://github.com/coreutils/coreutils/pull/398
2026-10-25 13:43:13 +00:00
Sylvestre Ledru 0445daffd6 tests: install: check leading directories ignore the umask
* tests/install/create-leading.sh: Ensure -D and -d create leading
directories with mode 755 under umask 077, and that --mode applies
only to the final component.
https://github.com/uutils/coreutils/pull/12715

Link: https://github.com/coreutils/coreutils/pull/397
2026-10-25 13:40:13 +00:00
Sylvestre Ledru 8c89b8a7d4 tests: chmod: check modes starting with an operator or a comma
* tests/chmod/usage.sh: Ensure modes like -=r, -+x and -,u+x are
taken as modes rather than options, check the resulting permissions,
and ensure -, is rejected.
https://github.com/uutils/coreutils/pull/15680

Link: https://github.com/coreutils/coreutils/pull/396
2026-10-25 13:39:40 +00:00
Sylvestre Ledru 20eb63dceb tests: chmod: check a name that is too long is diagnosed
* tests/chmod/partial-fail.sh: Ensure ENAMETOOLONG is reported for an
operand and for --reference, and that later operands are still
processed, with and without -R.
https://github.com/uutils/coreutils/pull/15499

Link: https://github.com/coreutils/coreutils/pull/396
2026-10-25 13:39:40 +00:00
Pádraig Brady ff1141fcec tests: make process cleanup more robust
* tests/cat/cat-buf.sh: Always call 'wait' in case the process already
exited before being killed.
* tests/cp/existing-perm-race.sh: Likewise.
* tests/cp/file-perm-race.sh: Likewise.
* tests/cp/parent-perm-race.sh: Likewise.
* tests/cp/sparse-to-pipe.sh: Likewise.
* tests/du/move-dir-while-traversing.sh: Likewise.
* tests/help/help-version.sh: Likewise.
* tests/misc/stdbuf.sh: Likewise.
* tests/mv/i-3.sh: Likewise.
* tests/printf/printf-surprise.sh: Likewise.
* tests/rm/isatty.sh: Likewise.
* tests/sort/sort-compress-proc.sh: Likewise.
* tests/sort/sort-spinlock-abuse.sh: Likewise.
* tests/tail/F-headers.sh: Likewise.
* tests/tail/F-vs-missing.sh: Likewise.
* tests/tail/F-vs-rename.sh: Likewise.
* tests/tail/append-only.sh: Likewise.
* tests/tail/assert-2.sh: Likewise.
* tests/tail/assert.sh: Likewise.
* tests/tail/debug.sh: Likewise.
* tests/tail/descriptor-vs-rename.sh: Likewise.
* tests/tail/follow-name.sh: Likewise.
* tests/tail/follow-stdin.sh: Likewise.
* tests/tail/follow-symlink.sh: Likewise.
* tests/tail/inotify-dir-recreate.sh: Likewise.
* tests/tail/inotify-hash-abuse.sh: Likewise.
* tests/tail/inotify-hash-abuse2.sh: Likewise.
* tests/tail/inotify-parent-hash.sh: Likewise.
* tests/tail/inotify-rotate.sh: Likewise.
* tests/tail/pid.sh: Likewise.
* tests/tail/pipe-f2.sh: Likewise.
* tests/tail/retry.sh: Likewise.
* tests/tail/symlink.sh: Likewise.
* tests/tail/tail-n0f.sh: Likewise.
* tests/tail/truncate.sh: Likewise.
* tests/tail/wait.sh: Likewise.
* tests/tee/tee.sh: Likewise.
* tests/timeout/timeout-group.sh: Likewise.
* tests/rm/dangling-symlink.sh: Likewise.
Also avoid redundant cleanup_ calls.
* tests/tail/flush-initial.sh: Likewise.
* tests/tail/inotify-rotate-resources.sh: Likewise.
2026-10-25 13:11:49 +00:00
Pádraig Brady f3d8e1ce30 tests: add extra protection to avoid changing system time
* tests/date/date-set.sh: Block "settime" syscalls with strace,
in case the test has (inherited) CAP_SYS_TIME.
2026-10-25 13:04:55 +00:00
Collin Funk 50a76c6ce0 mv: don't block when setting the SELinux security context on a FIFO
* src/selinux.c (restorecon_private): Open the file with O_NOCTTY and
O_NONBLOCK.
* tests/misc/selinux.sh: Add a test case.
* NEWS: Mention the bug fix.

Discovered by Anthropic's OSS Scanner, as bug ANT-2026-L5GJ7M7X.
2026-10-24 12:22:36 -07:00
Collin Funk e78a41cf8f tests: date: test that -u overrides the time zone when setting the time
This adds a test for the bug fixed by commit 9192fd32e (date: bring back
-u complexity with putenv, 2026-10-22).

* tests/date/date-set.sh: New file.
* tests/local.mk (all_tests): Add the new test.
* NEWS: Mention the bug fix.
2026-10-24 12:22:36 -07:00
Sylvestre Ledru 9cad3af5ce tests: ls: check -s rounds block counts up
* tests/ls/block-size.sh: Ensure ls -s rounds a partly used block up
when the block size does not divide the allocation, and that the
total scales the sum of the allocations once.
https://github.com/uutils/coreutils/pull/14330

Link: https://github.com/coreutils/coreutils/pull/395
2026-10-24 16:15:03 +01:00
Sylvestre Ledru 501d843fdb tests: csplit: check a suppressed line number one past the end
* tests/csplit/csplit-suppress-matched.pl (@csplit_tests): Add test
cases where --suppress-matched gets a line number one past the end
of input, alone, repeated, and after its previous line was already
suppressed.
https://github.com/uutils/coreutils/pull/15637

Link: https://github.com/coreutils/coreutils/pull/394
2026-10-24 16:15:03 +01:00
Sylvestre Ledru 4c91290e2d tests: od: check the offset width with -S
* tests/od/od.pl (@Tests): Add test cases for -S with -Ax, -Ad and -Ao,
ensuring hexadecimal offsets use 6 digits as in the normal dump.
https://github.com/uutils/coreutils/pull/15625

Link: https://github.com/coreutils/coreutils/pull/393
2026-10-24 16:15:03 +01:00
Sylvestre Ledru da597e49b4 tests: nl: check the current section carries over to the next file
* tests/nl/multiple-files.sh: Ensure a footer and a header started in
one input file go on in the next one, including stdin.
https://github.com/uutils/coreutils/pull/15629

Link: https://github.com/coreutils/coreutils/pull/392
2026-10-24 16:15:03 +01:00
Sylvestre Ledru d57d8187ca tests: join: check -i prints each line's own key
* tests/join/join.pl (@tv): Add test cases for -i with keys that
differ only in case, with the default output and with -o 0.
https://github.com/uutils/coreutils/pull/15635

Link: https://github.com/coreutils/coreutils/pull/391
2026-10-24 16:15:03 +01:00
Sylvestre Ledru b67fe9d035 tests: numfmt: check the first blank between fields is a space
* tests/numfmt/numfmt.pl (@Tests): Add test cases for tabs and
multiple blanks between fields, including echoed invalid lines
and an explicit delimiter.
https://github.com/uutils/coreutils/pull/15555

Link: https://github.com/coreutils/coreutils/pull/390
2026-10-24 16:15:03 +01:00
Sylvestre Ledru 16ef11d2bd tests: fmt: check a last line lacking the -p prefix keeps no newline
* tests/fmt/base.pl (@Tests): Add test cases for a last line without
a trailing newline, with and without the prefix.
https://github.com/uutils/coreutils/pull/15554

Link: https://github.com/coreutils/coreutils/pull/389
2026-10-24 16:15:03 +01:00
Sylvestre Ledru eac02dd7a2 tests: sort: check long lines survive an external sort
* tests/sort/sort.pl (@long_lines): New variable.
(@Tests): Add a test case sorting lines much longer than the buffer
with a small -S, so they go through temporary files.
https://github.com/uutils/coreutils/pull/15645

Link: https://github.com/coreutils/coreutils/pull/388
2026-10-24 16:15:03 +01:00
Sylvestre Ledru 782219ffa2 tests: sort: check -b and -M skip only space and tab
* tests/sort/sort.pl (@Tests): Add test cases ensuring a leading \f
or \r is not skipped by -b or -M, while space and tab still are.
https://github.com/uutils/coreutils/pull/15647

Link: https://github.com/coreutils/coreutils/pull/388
2026-10-24 16:15:02 +01:00
Sylvestre Ledru c0684d5bbb tests: sort: check a whole-line key's own reverse flag
* tests/sort/sort.pl (@Tests): Add test cases for a single key
covering the whole line with its own 'r' option, and for such a key
not inheriting the global -r.
https://github.com/uutils/coreutils/pull/15626

Link: https://github.com/coreutils/coreutils/pull/388
2026-10-24 16:15:02 +01:00
Mark Wielaard 45e98f93b3 cat: avoid apparent leaked FDs after splice
splice_cat can leave open file descriptors around. This breaks the
valgrind testsuite with --track-fds=yes. This is fairly innocent, like
still reachable memory, but does need a new suppression when tracking
file descriptor handling.  Introduce a new splice_cat_close function
that can be used on error from splice_cat and before exiting main.

* src/cat.c (splice_cat): Move static pipefd and pipefd_pipe_size to
file level, guarded by HAVE_SPLICE. Move pipefd close and cleanup from
error handler to...
(splice_cat_close): New function. Empty if we don't HAVE_SPLICE.
(main): Call splice_cat_close before exit.
2026-10-24 16:15:02 +01:00
Devel 2552293c5b tail: output an ERANGE error when unchanged stats flag is too small
Link: https://github.com/coreutils/coreutils/pull/387
2026-10-24 15:03:47 +01:00
Pádraig Brady e28a872b3a tests: avoid false failure with dash
* tests/cp/link-no-deref.sh: Use printf rather than echo, as echo
unconditionally interprets backslashes in dash.  Also use %q in
printf to decouple from the shell escaping implementation.
Also refactor strace usage to its own function, and avoid
a false failure in case strace didn't intercept the chown.
2026-10-24 14:39:50 +01:00
Collin Funk 499a55e03d cp: quote destination name when preserving ownership on symlinks fails
* src/copy.c (copy_internal): Add a missing quoteaf call.
* tests/cp/link-no-deref.sh: Invoke getlimits_ and uses_strace_. Inject
an error using 'strace' to verify the name of the destination is quoted
in the error message.

Discovered by Anthropic's OSS Scanner, as bug ANT-2026-3M3N6L8K.
2026-10-23 19:31:50 -07:00
Collin Funk aad192543e doc: dircolors: don't assume the shell starts in $HOME
* doc/coreutils.texi (dircolors invocation): Use an absolute path when
checking whether a user's .dircolors file exists in $HOME and when
loading it. Don't define a variable.

Discovered by Anthropic's OSS Scanner, as bug ANT-2026-HB2T3LWR.
2026-10-23 19:31:48 -07:00
Collin Funk 479317e6ce doc: dircolors: document reading from standard input
* src/dircolors.c (usage): Note that standard input is read when FILE is
"-".
* doc/coreutils.text (dircolors invocation): Likewise.
2026-10-23 19:31:38 -07:00
Collin Funk 2c2a1334fa factor: fix an infinite loop with some large numbers
* src/factor.c (mulredc2): Add the carry to p1, which is the high word
of a two-word integer created by summing two single-word integers and is
therefore unable to overflow, instead of using a low word r0, which may
wrap around by adding the carry.
* tests/factor/mulredc2-infloop.sh: New file.
* tests/local.mk (all_tests): Add the new test.
* NEWS: Mention the bug fix.

Discovered by Anthropic's OSS Scanner, as bug ANT-2026-CFUR0JKW.
2026-10-23 19:30:36 -07:00