Commit Graph
31893 Commits
Author SHA1 Message Date
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
Pádraig Brady 3a1595e2af cksum: improve --length diagnostics for negative numbers
Before:

  $ cksum --length -1 -a sha2 /dev/null
  cksum: invalid length: ‘-1’: Value too large for defined data type

After:

  $ cksum --length -1 -a sha2 /dev/null
  cksum: invalid length: ‘-1’
  cksum: digest length for ‘SHA2’ must be 224, 256, 384, or 512

* src/cksum.c: Avoid EOVERFLOW for negative numbers
(similarly to commit v9.5-71-gf2c84fe63).

Link: https://github.com/coreutils/coreutils/issues/386
2026-10-24 00:25:15 +01:00
Pádraig Brady 12244b4f2b tail: fix handling of inotify event queue overflow
* src/tail.c (tail_forever_inotify): Fallback to polling upon overlow.
* tests/tail/inotify-overflow.sh: Add a new test.
* tests/local.mk: Reference the new test.
* NEWS: Mention the bug fix.
Discovered by Anthropic's OSS Scanner, as bug ANT-2026-UUNT73BK.
2026-10-23 17:02:33 +01:00
Pádraig Brady 38aaf5e611 all: quote more user originated strings
* src/csplit.c: Quote arbitrary strings for clarity/safety.
* src/dircolors.c: Likewise.
* src/env.c: Likewise.
* src/split.c: Likewise.
* src/uniq.c: Likewise.
* tests/env/env-S.pl: Adjust accordingly.
* NEWS: Mention the improvement.
2026-10-23 14:08:24 +01:00
Paul Eggert 9192fd32e0 date: bring back -u complexity with putenv
This reverts my commit b64f9bfe4f
dated 2026-04-02.  I forgot that posixtime cares whether
-u has been specified, and gets that info via TZ.
It also uses xsetenv rather than the old putenv.
This fixes ANT-2026-LR8TONF4.
* configure.ac (LOCALTIME_CACHE): Bring this back.
* src/date.c (TZSET): Bring this back.
(main): Bring back setting TZ="UTC0" in the environment.
However, use xsetenv rather than putenv, as that’s simpler.
2026-10-22 21:21:18 -07:00
Pádraig Brady 4c4f2f55c3 basenc: fix incorrect base32hex input validation
* src/basenc.c (base32hex_decode_ctx_wrapper): Ensure we don't
accept base32 only characters for base32hex.
* tests/basenc/basenc.pl: Ensure negative base32hex tests have the
appropriate number of characters to test character validation
rather than just input size validation.
* NEWS: Mention the bug fix.

Discovered by Anthropic's OSS Scanner, as bug ANT-2026-EP1XO2G4.
2026-10-22 13:54:39 +01:00
Collin Funk 71a480bafa tests: factor: fix quoting of test input
* tests/factor/factor.pl: (@Tests): Wrap the input in double quotes so
the trailing space character is passed as an argument.
2026-10-21 22:00:05 -07:00
Collin Funk b919020cf5 factor: fix suffix validation on large integers
* src/factor.c (strtouuint): Return LONGINT_OVERFLOW only if all of the
characters are digits; otherwise, return LONGINT_INVALID.
* tests/factor/factor.pl: Add two test cases.
* NEWS: Mention the bug fix.
Discovered by Anthropic's OSS Scanner, as bug ANT-2026-IZ8PFQ7Q.
2026-10-21 20:00:43 -07:00
Pádraig Brady 6b9d96c694 build: update the gnulib submodule to latest
* gnulib: Update.
* NEWS: Mention the $GLIBC_TUNABLES improvement.
2026-10-21 17:49:20 +01:00
Pádraig Brady 218f81d978 stty: consistently honor the last specified speed
stty currently fails like:

  $ stty 9600
  $ saved=$(stty -g)
  $ stty 19200 "$saved"  # Sets 9600 but reports failure
  stty: 'standard input': unable to perform all requested operations

Whereas these work fine:

  $ stty 19200 9600
  $ stty "$saved" 19200

* NEWS: Mention the bug fix.
* src/speedgen (cbaud_to_speed): Determine the speed
from the control flag encoding.
* src/stty.c (recover_mode): If no separate speed specified,
update the speed from the specified control flags.
* tests/stty/stty-save-speed.sh: Add test cases.
2026-10-21 12:54:34 +01:00
Pádraig Brady 60e7bf4121 stty: support save/restore of speeds not encoded in control flags
Note this changes the output format of -g.
POSIX states that the -g format only needs to be compatible
with the stty implementation that produced it.
However we improve compatibility on Linux by only outputting
the explicit speeds when they're not encoded in the control flags.

* NEWS: Mention the change in behavior.
* src/stty.c (display_recoverable): Output the speeds if needed.
(recover_mode): Read the speeds if present.
* tests/stty/stty-save-speed.sh: Add a new test.
* tests/local.mk: Reference the new test.

Link: https://github.com/coreutils/coreutils/issues/384
2026-10-21 12:46:48 +01:00
Collin Funk 6800b46c52 tests: avoid use of $abs_path_dir_
* tests/cp/preserve-gid.sh: Prefer to find the programs to test
with `cmd_exe`.
2026-10-21 12:42:50 +01:00
Pádraig Brady ad7e743cff tests: avoid use of $abs_top_builddir where possible
* init.cfg (single_binary_build_): An abstraction to check
if the current build is a functional --enable-single-binary build.
(require_safe_builddir_): Also add an abstraction to check for
whitespace in $abs_top_builddir.
* tests/misc/proc-self-comm.sh: Just warn about a non functional
dispatch binary.
* tests/install/basic-1.sh: Use the abstraction which is more accurate
when a stub src/coreutils binary is present.
Also fix up an incorrect skip_ edge case.
* tests/misc/responsive.sh: Use require_safe_builddir_.
* tests/misc/stdbuf.sh: Likewise.
* tests/misc/exec-bad-unicode.sh: Clarify a comment.
2026-10-20 16:36:08 +01:00
Collin Funk 54e1938105 tests: avoid a false failure on some systems
* tests/misc/proc-self-comm.sh: Make sure the 'coreutils' program is the
one we just built.
Reported by Bruno Haible.
2026-10-19 20:05:56 -07:00
Collin Funk f8ba084b3f stty: don't treat baud rates of (speed_t) -1 as invalid
* src/stty.c (struct speed_desc): New type, used to differentiate
between errors and (speed_t) -1.
(last_ibaud, last_obaud): Define variables as struct speed_desc instead
of speed_t.
(check_speed): Adjust uses of last_ibaud and last_obaud to their new
definitions.
(set_speed): Likewise. Use a struct speed_desc as the argument instead
of speed_t. Check for its validity using the valid member instead of
whether it is equal to (speed_t) -1.
(apply_settings): Use struct speed_desc instead of speed_t to store the
result of string_to_baud. Check for its validity using the valid member
instead of whether it is equal to (speed_t) -1.
(string_to_baud): Adjust the function to return a struct speed_desc
instead of speed_t.
* src/speedgen (value_to_baud): Likewise.
* NEWS: Mention the bug fix.

Link: https://github.com/coreutils/coreutils/issues/383
2026-10-19 18:23:56 -07:00
Collin Funk cc6a346226 stty: reduce the number of strtoul calls
$ ltrace -c ./src/stty-prev 38400 2>&1 | grep 'strtoul$' \
        | cut --output-delimiter=' ' -w -f 5-6
    4 __isoc23_strtoul
    $ ltrace -c ./src/stty 38400 2>&1 | grep 'strtoul$' \
        | cut --output-delimiter=' ' -w -f 5-6
    2 __isoc23_strtoul

* src/stty.c (set_speed): Add a baud rate parameter. Remove a call to
string_to_baud.
(apply_settings): When calling string_to_baud, save the return value and
pass it to set_speed.
2026-10-19 18:23:56 -07:00
Pádraig Brady c543b3e56f doc: pr: improve the description of -a
* doc/coreutils.texi (pr invocation): Avoid the confusing
-COLUMN reference preferring the more standard --columns instead.
Fixes https://bugs.gnu.org/82075
2026-10-19 17:16:13 +01:00
Collin Funk 056730f7dd tests: misc: fix a false failure in paths containing spaces
* tests/misc/proc-self-comm.sh: Quote variables that contain the current
working directory, which may contain spaces. Don't set symlink_cat to a
multi-argument command invocation. Set the path before executing it.
Reported by Bruno Haible.
2026-10-18 17:43:23 -07:00
Collin Funk 1d5142dc09 all: use the basename of argv[0] for the comm value in the single binary
This preserves any program name transformations, e.g., when
--program-prefix=g is used as a configuration option, unlike commit
ef874ed6c (all: set /proc/self/comm to the program name in the single
binary, 2026-10-17).

* src/coreutils.c (launch_program): Use the last component of argv[0]
when setting the comm value using prctl (PR_SET_NAME, ...).
* tests/misc/proc-self-comm.sh: When using
--enable-single-binary=shebangs, test that the comm value preserves any
program name transformations, e.g., --program-prefix=g.
* NEWS: Adjust the NEWS entry to refer to last component of argv[0]
instead of the program name.
Suggested by Pádraig Brady.
2026-10-18 09:43:44 -07:00
Collin Funk 4886391906 doc: NEWS: mention the --enable-single-binary=symlinks comm value fix
* NEWS: Mention that the program name instead of argv[0] is used when
calling prctl (PR_SET_NAME, ...).
2026-10-16 21:16:10 -07:00
Collin Funk b5bc155d69 tests: misc: test that /proc/self/comm is properly set
This tests the fix introduced by commit ee9b9aff8 (all: set
/proc/self/comm to the program name in the single binary, 2026-10-17).

* tests/misc/proc-self-comm.sh: New file.
* tests/local.mk (all_tests): Add the new test.
2026-10-16 21:12:35 -07:00
Yu Watanabe ef874ed6ce all: set /proc/self/comm to the program name in the single binary
When built with --enable-single-binary=symlinks, the process name
(comm) previously contained the path component. Use prog_name instead of
argv[0] to set the correct process name without the path.

    Before:
    $ src/sleep 10000 &
    [1] 601333
    $ cat /proc/601333/comm
    src/sleep

    After:
    $ src/sleep 10000 &
    [1] 618100
    $ cat /proc/618100/comm
    sleep

* src/coreutils.c (launch_program): Use the program name instead of
argv[0] when calling prctl (PR_SET_NAME, ...).

Link: https://github.com/coreutils/coreutils/pull/382
2026-10-16 21:11:25 -07:00
Ismail Ramzi e9381ce5c7 maint: use to_uchar before isspace in --help markup
oputs_() scans the option text of translated usage strings and passes
each char directly to isspace().  Translated help text routinely holds
bytes >= 0x80, which are negative where char is signed, so isspace() is
called with a value outside its defined domain (unsigned char or EOF),
which is undefined behavior.  Route the arguments through to_uchar() as
done for ctype calls elsewhere in src/.

* src/system.h (oputs_): Pass isspace() arguments through to_uchar().
Copyright-paperwork-exempt: Yes

Link: https://github.com/coreutils/coreutils/pull/381
2026-10-16 21:57:23 +01:00
Collin Funk e3dd28f790 maint: ptx: use a stricter COUNTED_BY for the word table
* src/ptx.c (WORD_TABLE): Change the COUNTED_BY to use the length member
instead of alloc.
(digest_word_file): Increment the length before appending to the table
otherwise -fsanitize=bounds would kill the program.
2026-10-16 00:15:31 -07:00
Collin Funk 051456d414 maint: split: use COUNTED_BY for the list of open pipes
* src/split.c (open_pipes): Define as a struct containing the previously
global variables. Use COUNTED_BY.
(open_pipes_alloc, n_open_pipes): Remove variables moved into the newly
added struct.
(create): Update uses of the previously existing globals to reference
the open_pipes struct.
(closeout): Likewise. Don't decrement the pipe bounds until after we
make our final access to the last pipe in the array, to satisfy the
requirements of the COUNTED_BY attribute.
2026-10-15 17:33:05 -07:00
Collin Funk 4524916551 maint: sort: use COUNTED_BY for the list of temporary directories
* src/sort.c (temp_dirs): Define as a struct containing the previously
global variables. Use COUNTED_BY.
(temp_dir_count, temp_dir_alloc): Remove variables moved into the newly
added struct.
(create_temp_file, open_temp, main): Update uses of the previously
existing globals to reference the temp_dirs struct.
2026-10-15 17:33:05 -07:00
Pádraig Brady 18eca48b40 build: remove wget as a hard dependency
* bootstrap.conf (buildreq): Remove "wget" as that is only
needed for po downloads and that can be skipped wth --skip-po.
2026-10-15 14:29:55 +01:00
Collin Funk 5f2ad8da28 maint: df: refactor rows and columns to use COUNTED_BY
* src/df.c (table): Define as a struct containing the previously global
variables. Use COUNTED_BY.
(columns, ncolumns, ncolumns_alloc, nrows, nrows_alloc): Move into the
table struct.
(alloc_table_row, print_table, alloc_field, get_field_list, get_header)
(get_dev): Update uses of the previously existing globals to reference
the table struct.
2026-10-14 17:36:28 -07:00
Collin Funk ae58eee442 maint: factor: use a stricter COUNTED_BY on the list of factors
* src/factor.c (struct mp_factors): Change the COUNTED_BY to use the
nfactors member instead of nalloc.
2026-10-14 17:36:28 -07:00