Commit Graph
5822 Commits
Author SHA1 Message Date
Sylvestre Ledru 566aeee281 tests: realpath: ensure realpath -s -e fails on a dangling symlink
Reported at https://github.com/uutils/coreutils/issues/15996

* tests/misc/realpath.sh: Add test case.

Link: https://github.com/coreutils/coreutils/pull/432
2026-11-07 12:35:10 +00:00
Sylvestre Ledru cedefc7896 tests: readlink: ensure the last of readlink's -e, -f and -m wins
Reported at https://github.com/uutils/coreutils/issues/15995

* tests/readlink/can-e.sh: Add test cases.

Link: https://github.com/coreutils/coreutils/pull/431
2026-11-07 12:35:10 +00:00
Sylvestre Ledru bb0ffe17f7 tests: paste: ensure paste names the file in open and read errors
Reported at https://github.com/uutils/coreutils/issues/15983

* tests/paste/paste.pl: Add test cases.

Link: https://github.com/coreutils/coreutils/pull/430
2026-11-07 12:35:10 +00:00
Sylvestre Ledru 30f5713ede tests: od: ensure od rejects an output type combined with --strings
Reported at https://github.com/uutils/coreutils/issues/15989

* tests/od/od.pl: Add test cases.

Link: https://github.com/coreutils/coreutils/pull/429
2026-11-07 12:35:10 +00:00
Sylvestre Ledru d6efb32a53 tests: od: ensure od prints the final offset even when an input fails
Reported at https://github.com/uutils/coreutils/issues/15990

* tests/od/od.pl: Add test case.

Link: https://github.com/coreutils/coreutils/pull/428
2026-11-07 12:35:10 +00:00
Sylvestre Ledru d004eacceb tests: numfmt: ensure unambiguous abbreviations of option values work
Reported at https://github.com/uutils/coreutils/issues/16005

* tests/numfmt/numfmt.pl: Add test cases.

Link: https://github.com/coreutils/coreutils/pull/427
2026-11-07 12:35:10 +00:00
Sylvestre Ledru 5d793a1521 tests: nl: ensure nl accepts negative -v and -i values
Reported at https://github.com/uutils/coreutils/issues/15999

* tests/nl/nl.sh: Add test cases.

Link: https://github.com/coreutils/coreutils/pull/426
2026-11-07 12:35:10 +00:00
Sylvestre Ledru c1265262f9 tests: mkdir, mkfifo: ensure a numeric mode followed by ',' is rejected
Reported at https://github.com/uutils/coreutils/issues/16001

* tests/misc/mknod.sh: Add test cases.

Link: https://github.com/coreutils/coreutils/pull/425
2026-11-07 12:35:10 +00:00
Sylvestre Ledru 68d3c16f99 tests: mkdir: ensure --context takes an optional argument
Reported at https://github.com/uutils/coreutils/issues/16002

* tests/mkdir/context-optional.sh: New test.
* tests/local.mk: Reference the new test.

Link: https://github.com/coreutils/coreutils/pull/424
2026-11-07 12:35:10 +00:00
Sylvestre Ledru 98a6a87701 tests: sum: ensure the last of -r and -s wins
Reported at https://github.com/uutils/coreutils/issues/15986

* tests/cksum/sum.pl: Add test cases.

Link: https://github.com/coreutils/coreutils/pull/423
2026-11-07 12:35:10 +00:00
Sylvestre Ledru e2d537ace6 tests: mkfifo: ensure a -m value starting with '-' is accepted
Reported at https://github.com/uutils/coreutils/issues/16000

* tests/misc/mknod.sh: Add test case.

Link: https://github.com/coreutils/coreutils/pull/422
2026-11-07 12:35:10 +00:00
Sylvestre Ledru c310a8f0e5 tests: cp, ln, mv, install: ensure an empty --backup= acts like --backup
Reported at https://github.com/uutils/coreutils/issues/15988

* tests/misc/empty-backup-suffix.sh: Add test cases.

Link: https://github.com/coreutils/coreutils/pull/421
2026-11-07 12:35:10 +00:00
Sylvestre Ledru ddcabc55b5 tests: ls: ensure --block-size=0 is rejected despite later size options
Reported at https://github.com/uutils/coreutils/issues/16008

* tests/ls/ls-misc.pl: Add test cases.

Link: https://github.com/coreutils/coreutils/pull/420
2026-11-07 12:35:10 +00:00
Sylvestre Ledru 7387195296 tests: ln: ensure --verbose uses '=>' for hard links, '->' for symlinks
Reported at https://github.com/uutils/coreutils/issues/15985

* tests/ln/misc.sh: Add test cases.

Link: https://github.com/coreutils/coreutils/pull/419
2026-11-07 12:35:10 +00:00
Sylvestre Ledru a1974b5605 tests: join: ensure the last of --check-order and --nocheck-order wins
Reported at https://github.com/uutils/coreutils/issues/16004

* tests/join/join.pl: Add test cases.

Link: https://github.com/coreutils/coreutils/pull/418
2026-11-07 12:35:10 +00:00
Sylvestre Ledru d77e262e13 tests: head: ensure a count is validated even when later overridden
Reported at https://github.com/uutils/coreutils/issues/15997

* tests/head/head.pl: Add test cases.

Link: https://github.com/coreutils/coreutils/pull/417
2026-11-07 12:35:10 +00:00
Sylvestre Ledru 9233e94688 tests: expand, unexpand: ensure a bare '-' is treated as standard input
Reported at https://github.com/uutils/coreutils/issues/15658

* tests/expand/expand.pl: Add test case.
* tests/unexpand/unexpand.pl: Add test cases.

Link: https://github.com/coreutils/coreutils/pull/416
2026-11-07 12:35:10 +00:00
Sylvestre Ledru bea11752b3 tests: env: ensure an unset variable on its own adds no argument with -S
Reported at https://github.com/uutils/coreutils/issues/15773

* tests/env/env-S.pl: Add test cases.

Link: https://github.com/coreutils/coreutils/pull/415
2026-11-07 12:35:10 +00:00
Sylvestre Ledru 3c77964c82 tests: env: ensure env -a requires a command
Reported at https://github.com/uutils/coreutils/issues/15991

* tests/env/env.sh: Add test cases.

Link: https://github.com/coreutils/coreutils/pull/414
2026-11-07 12:35:10 +00:00
Sylvestre Ledru 8df8852fdc tests: du: ensure -P after --dereference-args wins
Reported at https://github.com/uutils/coreutils/issues/16003

* tests/du/deref-args.sh: Add test cases.

Link: https://github.com/coreutils/coreutils/pull/413
2026-11-07 12:35:10 +00:00
Sylvestre Ledru 69a724b968 tests: cp: ensure cp rejects --link combined with --symbolic-link
Reported at https://github.com/uutils/coreutils/issues/15987

* tests/cp/link.sh: Add test cases.

Link: https://github.com/coreutils/coreutils/pull/412
2026-11-07 12:35:10 +00:00
Sylvestre Ledru e9de147d5a tests: cksum: ensure an explicit '-' operand is printed as the file name
Reported at https://github.com/uutils/coreutils/issues/15984

* tests/cksum/cksum.sh: Add test cases.

Link: https://github.com/coreutils/coreutils/pull/411
2026-11-07 12:35:10 +00:00
Sylvestre Ledru d1f6125ecf tests: chmod: ensure --reference processes operands in order
Reported at https://github.com/uutils/coreutils/issues/15666

* tests/chmod/reference-order.sh: New test.
* tests/local.mk: Reference the new test.

Link: https://github.com/coreutils/coreutils/pull/410
2026-11-07 12:35:10 +00:00
Sylvestre Ledru 529612a8ae tests: basenc: ensure --base64url decodes input without '=' padding
Reported at https://github.com/uutils/coreutils/issues/15664

* tests/basenc/basenc.pl: Add test cases.

Link: https://github.com/coreutils/coreutils/pull/409
2026-11-07 12:35:10 +00:00
Collin Funk 605a37ee1e shred: quote file names in --verbose output when renaming them
* src/shred.c (wipename): Quote the names of the source and destination
when printing verbose messages for rename. Remove comment about not
needing quoting after the first message, since we still do not control
the contents of any parent directories contained in the source or
destination.
* tests/shred/verbose-quote.sh: New file.
* tests/local.mk (all_tests): Add the new test case.
* NEWS: Mention the bug fix.

Discovered by Anthropic's OSS Scanner, as bug ANT-2026-3UJ1SMSY.
2026-11-06 17:06:42 -08:00
Sylvestre Ledru 6d094859b0 tests: tr: ensure [c*] and [=c=] in string2 are only allowed where valid
Reported at https://github.com/uutils/coreutils/issues/15589

* tests/tr/tr.pl: Add test cases.

Link: https://github.com/coreutils/coreutils/pull/408
2026-11-06 23:55:28 +00:00
Pádraig Brady 67b6801ad3 cksum: use more defensive file name escaping
Similarly to commit v9.10-115-gb3fe24213, which applied
the same quoting mechanism to --check operation,
also quote file names when generating checksums to tty.
This change gives these advantages:

  1. Avoids dumping arbitrary data to vulnerable terminals
  2. Avoids visual deception with ansi codes with unknown file names
  3. More secure if users copy and paste file names from output

* doc/coreutils.texi (sum invocation): Mention the tty quoting
and reference the details from ...
(cksum output modes): Describe the two forms of quoting used.
* tests/misc/tty-quoting.sh: Add test cases.
* NEWS: Mention the improvement.

Discovered by Anthropic's OSS Scanner, as bug ANT-2026-Z25BP6MW.
2026-11-06 23:55:00 +00:00
Collin Funk 37f04509c9 install: execute 'strip' in the current working directory with -D
* src/install.c (mkancesdirs_safe_wd): Save the current working
directory when using 'strip' on files.
* tests/install/strip-program.sh: Add two test cases.
* NEWS: Mention the bug fix.

Discovered by Anthropic's OSS Scanner, as bug ANT-2026-CBHGSM1T.
2026-11-05 19:22:08 -08:00
Collin Funk 368ca3629b mv: don't lose ENOENT errors when --exchange is used
This fixes the following error message:

    $ touch a; mv --exchange a b
    mv: cannot exchange 'a' and 'b': Unknown error -1

Here is the error message after this commit:

    $ touch a; ./src/mv --exchange a b
    mv: cannot exchange 'a' and 'b': No such file or directory

* THANKS.in: Add Igor Giamoniano, who reported the bug.
* src/copy.c (copy_internal): Save the EEXIST errno when stat fails,
since renameat would fail for the same reason.
* tests/mv/mv-exchange.sh: Add a few test cases where the bug could be
seen.
* NEWS: Mention the bug fix.
Fixes https://bugs.gnu.org/82186
2026-11-05 18:27:53 -08:00
Li Guan fd366bec13 tests: dd: support 4 KiB alignment for direct I/O
Some file systems/device combinations reject 512-byte direct writes
with EINVAL but accept 4 KiB writes.
Try 4 KiB blocks before skipping the direct I/O test.

* tests/dd/direct.sh: Probe 512-byte blocks first and fall back to
4 KiB blocks.  Use the selected input and output block sizes in each
test case, and size the short input to one byte less than a block.

Link: https://github.com/coreutils/coreutils/pull/406
2026-11-05 17:28:27 +00:00
Pádraig Brady 3f01618856 tests: shred: check for chmod race
* tests/shred/chmod-race.sh: Add a new test, which is
the first in the test suite to use strace to STOP a process.
* tests/local.mk: Reference the new test.
2026-11-04 13:04:07 +00:00
Collin Funk 95063b7ddc dircolors: escape history substitution when using csh syntax
* src/dircolors.c (syntax): New global variable.
(append_quoted): Escape '!' if we are using 'csh' syntax to prevent
history substitution.
(main): Remove the syntax variable that was made global.
* tests/misc/dircolors.pl (@Tests): Add a test case.
* NEWS: Mention the bug fix.

Discovered by Anthropic's OSS Scanner, as bug ANT-2026-SFBDLZ6V.
2026-11-03 22:44:37 -08:00
Collin Funk 7b48dd18cd tests: shred: check the behavior when close fails
* tests/shred/failed-close.sh: New file.
* tests/local.mk (all_tests): Add the new test case.
2026-11-03 20:19:47 -08:00
Collin Funk bfceb45637 shred: fix races with --force and --remove
* src/shred.c (wipefile): When --force or --remove are in use, and the
file is in a subdirectory, open a file descriptor to its parent and
perform operations on the basename relative to it.
(wipename): Add a file descriptor argument to the parent directory. Open
a readable file descriptor to the directory if we need to sync it. Use
the file descriptor with renameatu and unlinkat.
* tests/shred/unlink-race.sh: New file.
* tests/local.mk (all_tests): Add the new test case.
* NEWS: Mention the bug fixes.

Discovered by Anthropic's OSS Scanner, as bug ANT-2026-O4Q4UVP2.
2026-11-03 20:16:05 -08:00
Pádraig Brady 1704600adc split: make the last specified --{hex,numeric} set the start
Given the FROM argument is interpreted as a different base
for --hex-suffixes and --numeric-suffixes, it makes more
sense for a previous start value to be discarded.

* doc/coreutils.texi: Mention this for --hex-suffixes,
and also mention the FROM argument is interpreted as hex.
* src/split.c (main): Just reset numeric_suffix_start,
and avoid reinterpretation validation.
* tests/split/numeric.sh: Adjust accordingly.
* NEWS: Mention the change in behavior.
2026-11-03 13:28:02 +00:00
Ismail Ramzi a65907555f split: fix out-of-bounds read with --hex-suffixes=FROM
When FROM contained the digits a-f, next_file_name() derived the
suffix index with c - '0', giving values up to 54 for a 16 character
alphabet.  Incrementing the suffix then read past the end of the
alphabet string and used those bytes in the output file names,
e.g., 'split --hex-suffixes=f' created x0f, x0s, x0u.

* src/split.c (next_file_name): Map start value characters through
the suffix alphabet rather than assuming decimal digits.
(main): Reject a start value not valid for the final suffix alphabet,
as can happen with --hex-suffixes=a --numeric-suffixes.
(set_suffix_length): Determine width using base 16 for hex suffixes.
* tests/split/numeric.sh: Add test cases.
* NEWS: Mention the bug fix.

Link: https://github.com/coreutils/coreutils/pull/404
Also discovered by Anthropic's OSS Scanner, as bug ANT-2026-DWADVADP.
2026-11-03 13:28:02 +00:00
Pádraig Brady d8df89c29d tests: fix false failure with spaces in the path
* tests/sort/sort-compress.sh: Quote the found sort exe.
Reported by Bruno Haible.
2026-11-03 13:23:47 +00:00
Pádraig Brady c509ca06d4 seq: fix handling of locale decimal point and upper case hex floats
* src/seq.c (scan_arg): Search for the locale decimal point.
Also handle uppercase 'P' in hex format floats.
(main): Recognize locale decimal point in apparent options.
* tests/seq/seq-locale.sh: Add test cases.
* NEWS: Mention the bug fix.

Discovered by Anthropic's OSS Scanner, as bug ANT-2026-ERV7HOGN.
2026-11-02 23:43:14 +00:00
Pádraig Brady e85bf8468f seq: ensure termination at floating point limits
* src/seq.c (dump_strings): Rearrange limit checks to
reduce rounding affects.  Also add sanity check on
on the iteration number limit.
* tests/seq/seq-no-progress.sh: Add a new test.
* tests/local.mk: Reference the new test.
* NEWS: Mention the fix.

Discovered by Anthropic's OSS Scanner, as bug ANT-2026-RI0OLUBX.
2026-11-02 23:42:42 +00:00
Collin Funk f30c663c73 sort: use a default PATH when the environment variable is undefined
* gnulib: Update to get commit 19e602707d (findprog-in: Use a default
PATH like POSIX specifies., 2026-11-02).
* tests/sort/sort-compress.sh: Add a test case.
* NEWS: Mention the bug fix.

Discovered by Anthropic's OSS Scanner, as bug ANT-2026-1R7RAVAG.
2026-11-02 15:30:16 -08:00
Ismail Ramzi 66d443b198 nl: fix argument corruption with multiple -d arguments
A single character --section-delimiter is completed with an implied ':'
by writing through section_del, which is assumed to still point at the
static DEFAULT_SECTION_DELIMITERS buffer.  After an earlier -d with zero
or more than one character, section_del points at that argument instead,
so the write goes into the earlier argv string and past its end.
In a UTF-8 locale 'nl -d "" FILE -d x' corrupts the FILE operand,
and in the C locale 'nl -d foo -d x' uses the delimiter "xoo".

* src/nl.c (main): Point section_del at the static buffer before
building the single character delimiter.
* tests/nl/nl.sh, tests/nl/multibyte.sh: Add test cases.
* NEWS: Mention the bug fix.
Bug present since coreutils 9.0.

Link: https://github.com/coreutils/coreutils/pull/403
2026-11-02 13:58:12 +00:00
Collin FunkandPádraig Brady e018661bd9 chcon: avoid a race when partial contexts are specified
* src/chcon.c: Include fcntl--.h.
(change_file_context): Open a file descriptor when only a partial
context is specified. Use it to get and subsequently set the file
context, instead of using getfileconat followed by setfileconat, if
libselinux supports it on a file descriptor opened with O_PATH.
* tests/chcon/traversal-missing.sh: Adjust the test using partial
contexts to also inject open and openat errors. Add a test for complete
contexts.
* NEWS: Mention the bug fix.

Discovered by Anthropic's OSS Scanner, as bug ANT-2026-9PFL6OLT.

Co-authored-by: Pádraig Brady <P@draigBrady.com>
2026-11-01 19:26:16 -08:00
Collin Funk 3d2af4cac4 tests: mkfifo: add some basic test cases
* tests/mkfifo/basic.sh: New file.
* tests/local.mk (all_tests): Add the new test.
2026-10-31 23:03:30 -07:00
Pádraig Brady 1d52335d5b od: with --strings, exit promptly upon write error
* tests/misc/write-errors.sh: Add a test case.
* src/od.c (dump_strings): Call write_error() in the processing loop.
* NEWS: Mention the improvement.
2026-10-31 17:57:30 +00:00
Pádraig Brady 171b53a95d od: fix failure to continue processing inputs on read error
* NEWS: Mention the bug fix.
* src/od.c (dump): Don't break the look on read error.
* tests/od/od.pl: Add a test case.

Discovered by Anthropic's OSS Scanner, as bug ANT-2026-DYUIRPOE.
Link: https://github.com/coreutils/coreutils/issues/402
2026-10-31 17:57:29 +00:00
Collin Funk 83545af2a8 tail: allocate a large enough inotify event buffer
* src/tail.c (tail_forever_inotify): Size the buffer based on NAME_MAX
instead of the operands. Reduce the scope of some variables.
* tests/tail/inotify-long-name.sh: New file.
* tests/local.mk (all_tests): Add the new test.
* NEWS: Mention the bug fix. Adjust the reference in a previously fixed
bug to mention it was introduced with inotify support.

Discovered by Anthropic's OSS Scanner, as bug ANT-2026-S9L24ERC.
2026-10-30 17:59:19 -07:00
Pádraig Brady 977b071eaf tests: add checks for recent strftime fixes
Add docs and tests for the recent gnulib strftime fixes.

* tests/misc/strftime.sh: Add a new test.
* tests/local.mk: Reference the new test.
* NEWS: Mention the bug fixes.
Fixes https://bugs.gnu.org/82130
2026-10-30 17:58:15 +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 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