Commit Graph
5579 Commits
Author SHA1 Message Date
Guanqiang Han 9342ddbd71 pr: guard input position update against overflow
* src/pr.c (char_to_clump): Use ckd_add() and report integer overflow.
* tests/pr/options.sh: Add a test case.
* NEWS: Mention the bug fix.
Fixes https://bugs.gnu.org/81393
2026-07-10 22:19:46 +01:00
Pádraig Brady 36d1a194a9 factor: avoid out-of-bounds prime table access
With an ASAN build we can trigger the issue like:

  $ src/factor 22486472939460651857
  src/factor.c:888:36: runtime error:
  index 675 out of bounds for type 'int_least16_t [675]'

* src/factor.c (factor_using_division): Guard the final unrolled block
before reading a subsequent prime.
* tests/factor/factor.pl: Add a test case.
* NEWS: Mention the bug fix.
Problem caught by Coverity analysis.
2026-07-10 12:12:41 +01:00
Sylvestre Ledru 68f15d9128 tests: numfmt: check --header does not swallow a following operand
* tests/numfmt/numfmt.pl (header-10): New test verifying that --header,
which only accepts an argument via '=', does not consume a following
operand as its value.
https://github.com/uutils/coreutils/pull/13273

Link: https://github.com/coreutils/coreutils/pull/312
2026-07-06 14:25:59 +01:00
Sylvestre Ledru 440fe62502 tests: ls: check that an invalid --tabsize is diagnosed
* tests/ls/ls-misc.pl: Add tests, generated by a loop over invalid
values, verifying that a negative (-9), non-numeric (zz), or
fractional (0.5) --tabsize argument is rejected with
"invalid tab size" and exit status 2.
https://github.com/uutils/coreutils/pull/13278

Link: https://github.com/coreutils/coreutils/pull/311
2026-07-06 14:23:58 +01:00
Collin Funk 165b62de80 du: treat negative --max-depth values as errors
* NEWS: Mention the bug fix.
* src/du.c (main): Prefer ckd_add to check for overflow. Emit an error
if the value is negative.
* tests/du/max-depth.sh: Add a test case for the bug.
2026-07-03 20:29:48 -07:00
oech3 a463a6e6ee tests: nproc: support referencing of external command
* tests/nproc/nproc-quota.sh: Use command -v nproc instead of
$abs_top_builddir for external usage of tests.
Also quote "$nproc" usage, to support spaces in path.

Link: https://github.com/coreutils/coreutils/pull/310
2026-07-03 10:51:57 +01:00
Pádraig Brady d73d2d1b31 tests: nproc: support more general syscall injection
* tests/nproc/nproc-quota.sh: Prefer strace to LD_PRELOAD,
as it's simpler and supports static executables.
https://github.com/coreutils/coreutils/issues/309
2026-07-02 11:21:47 +01:00
Pádraig Brady e45a3f6a19 tests: avoid false failure where mknod() can't create sockets
* tests/mv/mv-special-1.sh: Adjust the python probe to more
closely match how copy.c creates sockets, as otherwise we
get a false failure on systems where mknod() fails with S_IFSOCK,
which was seen on Solaris and FreeBSD at least.
* tests/mv/mv-special-2.sh: Adjust similarly as this
was a latent issue on this root only test.
Reported by Bruno Haible.
2026-07-02 00:58:18 +01:00
Collin Funk 4c234d7555 tests: csplit: avoid a false failure on NetBSD
* tests/csplit/csplit.sh: Don't run the test if calling read on a
directory file descriptor works.
Reported by Bruno Haible.
2026-06-30 20:04:10 -07:00
Pádraig Brady d2428b1f26 tests: mv: check cross-fs replacement with special files
* tests/mv/mv-special-1.sh: Moving a socket onto an existing file
on another file system must replace that file, and not for example
unlink the destination first and then fail, leaving the user
with neither file.

Link: https://github.com/coreutils/coreutils/pull/303
2026-06-30 19:04:23 +01:00
Sylvestre Ledru 970548101e tests: shuf: check -o output is preserved when the run fails
A failed shuf invocation should leave an existing output file untouched
rather than truncating it before the failure is detected.
* tests/shuf/shuf.sh: Verify that a missing input file or an unreadable
random source leaves an existing -o file unchanged.

Link: https://github.com/coreutils/coreutils/pull/304
2026-06-30 18:26:51 +01:00
Sylvestre Ledru 7dd7fd17b9 tests: ls: check C1 control char escaping in UTF-8 quoting
* tests/ls/quoting-utf8.sh: A non-ASCII C1 control character (U+0085
NEL) is not printable, so locale/clocale quoting must octal-escape its
bytes (\302\205) rather than emit them literally.  Add a file named
with U+0085 and verify the escaped form for both styles.
gap identified here: https://github.com/uutils/coreutils/pull/13150

Link: https://github.com/coreutils/coreutils/pull/306
2026-06-30 18:21:36 +01:00
Sylvestre Ledru 9502f05a30 tests: realpath: a trailing slash must not require read permission
A trailing slash only asserts that the operand is a directory.  That
is a stat-level check, needing search permission on the parent, not
read permission on the directory itself.
* tests/misc/realpath.sh: Check that a searchable but unreadable
directory still resolves with a trailing slash, with and without -e.

Link: https://github.com/coreutils/coreutils/pull/307
2026-06-30 16:27:15 +01:00
Sylvestre Ledru 0eb2fff613 tests: cp: --remove-destination must honor the same-file check
* tests/cp/same-file.sh: A different spelling of the same path
('foo' vs './foo') must still be detected as the same file, so
--remove-destination refuses instead of unlinking the source.

Link: https://github.com/coreutils/coreutils/pull/302
2026-06-29 20:42:59 +01:00
Collin Funk 52ff9b97fb uniq: avoid locking standard output when printing line counts with -c
This increases throughput on systems with unlocked stdio functions.
E.g., 2.5x in the following case:

    $ timeout 1m taskset 1 shuf -r -i 0-100 \
        | taskset 2 uniq -c \
        | taskset 3 pv -r > /dev/null
    [ 100MiB/s]
    $ timeout 1m taskset 1 shuf -r -i 0-100 \
        | taskset 2 uniq -c \
        | taskset 3 pv -r > /dev/null
    [ 246MiB/s]

* src/uniq.c: Include assure.h.
(writeline): Convert the value to a string by hand and use fwrite, which
may be unlocked, instead of printf.
* tests/uniq/uniq-c-width.sh: New test to verify the padding logic.
* tests/local.mk (all_tests): Add the test case.
* NEWS: Mention the improvement.
2026-06-28 19:44:00 -07:00
Collin Funk d7622d8629 tests: csplit: also test a read failure without -k
* tests/csplit/csplit.sh: Adjust the test case added by the previous
commit to also run without the -k option.
2026-06-27 16:14:34 -07:00
Collin Funk cd381f4afd tests: csplit: check for message to standard output after read fails
* tests/csplit/csplit.sh: Add a test case.
2026-06-27 12:48:19 -07:00
Collin Funk 57fe9ecd69 tests: dd: check that files are opened with O_TRUNC
* tests/dd/misc.sh: Add the test case.
2026-06-24 21:08:33 -07:00
Collin Funk 17e6bfcc2b tests: date: remove a non-portable test
This test failure was seen on FreeBSD, NetBSD, and OpenBSD.

* tests/date/date-tz.sh: Remove the test case.
Reported by Bruno Haible.
2026-06-23 18:26:21 -07:00
Collin Funk 05d237cc56 tests: sort: check that invalid --parallel arguments are diagnosed
* tests/sort/sort.pl (@Tests): Add a few test cases.
2026-06-21 19:11:51 -07:00
aizu-m 6a850b9aac wc: fix out-of-bounds read for single-byte wide characters
In legacy CJK locales a single input byte can decode to a wide character
above UCHAR_MAX, e.g. SHIFT-JIS bytes 0xA1..0xDF become U+FF61..U+FF9F.
wc then indexed its 256-entry wc_isprint/wc_isspace tables with that
value and read past their end.
* src/wc.c (wc): Take the byte-indexed fast path only when the decoded
character fits in a byte; wider values fall through to c32width and
c32isspace.
* tests/wc/wc-sjis.sh: New test.
* tests/local.mk (all_tests): Add it.
* NEWS: Mention the fix.

Link: https://github.com/coreutils/coreutils/pull/298
2026-06-19 15:39:10 +01:00
Collin Funk 04b757da79 tests: cp,install,mv: check for data loss with just-created files
* tests/misc/just-created.sh: New file.
* tests/local.mk (all_tests): Add the test case.
2026-06-18 19:31:39 -07:00
Pádraig Brady 144287129e tests: nproc: ensure affinity mask is independent of scheduler
* tests/nproc/nproc-quota-systemd.sh: Check affinity mask with
various schedulers.
https://github.com/coreutils/coreutils/pull/291
2026-06-18 16:35:17 +01:00
oech3 19fb2a9aa3 tests: nproc: ensure OMP_NUM_THREADS overflow is clamped
* tests/nproc/nproc-override.sh: Test overflowed OMP_NUM_THREADS.
https://github.com/coreutils/coreutils/pull/292
2026-06-18 16:15:26 +01:00
oech3 196956dff9 tests: nproc: ensure --ignore clamps overflowed num
* tests/nproc/nproc-positive.sh: Test --ignore overflowed num
is clamped to $UINTMAX_MAX.
https://github.com/coreutils/coreutils/pull/293
2026-06-18 15:50:45 +01:00
Pádraig Brady 5800d91721 tests: nproc: ensure scheduler and OMP_NUM_THREADS are independent
* tests/nproc/nproc-quota-systemd.sh: Explicitly set OMP_NUM_THREADS
to an ignorable value, to ensure scheduler processing is independent.
* tests/nproc/nproc-quota.sh: Likewise for the SCHED_FIFO check.
https://github.com/coreutils/coreutils/pull/290
2026-06-18 15:38:18 +01:00
oech3 c5d2f42c43 tests: split: ensure no files created with no input
* tests/split/split-io-err.sh: Ensure 'xaa' is not opened/created
with empty input.
https://github.com/coreutils/coreutils/pull/297
2026-06-18 14:20:35 +01:00
Collin Funk da1d289554 tests: date: test -d with only a minus sign
* tests/date/date.pl (@Tests): Add the test case.
2026-06-16 20:20:36 -07:00
oech3 bd649cca23 tests: nice: add test for --adjustment long option
* tests/nice/nice.sh: Ensure (abbreviated) long option is supported.
https://github.com/coreutils/coreutils/pull/296
2026-06-16 18:48:15 +01:00
Collin Funk fa1ad3fa07 tests: split: avoid a false failure when ulimit fails
* tests/split/suffix-length.sh: Don't fail the test case if ulimit
fails.
Reported by Bruno Haible.
2026-06-15 22:06:22 -07:00
Collin Funk 16d292f065 tests: test: test numeric operators with -l STRING
* tests/test/test.pl (@Tests): Add a few test cases.
2026-06-14 22:50:50 -07:00
Collin Funk efeac27389 tests: date: test time zone format strings with space padding
* tests/date/date.pl (@Tests): Add a few test cases.
2026-06-14 16:19:06 -07:00
Collin Funk 60f342dc97 build: update gnulib submodule to latest
This imports a xstrtol-error change from Gnulib that fixes some error
messages that were not properly escaped when given an invalid integer
argument.

* .gitignore: Add /lib/thread-creators.h which is generated by Gnulib.
* gnulib: Update to the latest commit.
* tests/od/od.pl (@Tests): Add some test cases.
* NEWS: Mention the improvement.
2026-06-14 15:20:26 -07:00
Collin Funk 2a7d111818 tests: date: test that multiple time zone abbreviations cause an error
* tests/date/date.pl (@Tests): Add two test cases.
2026-06-14 11:15:03 -07:00
Collin Funk befdbed2f9 test: tail: test that --follow works on a symbolic link
* tests/tail/follow-symlink.sh: New file.
* tests/local.mk (all_tests): Add the test.
2026-06-14 10:52:46 -07:00
Collin Funk dfb89db157 tests: od: test command line arguments are checked for overflow
* tests/od/od.pl ($INTMAX_OFLOW): Add definition.
(@Tests): Test -j, -N, -S, and -w with $INTMAX_OFLOW.
2026-06-13 15:30:42 -07:00
Pádraig Brady bb55b57c0a tests: pr: add more numeric option tests
* tests/pr/options.sh: Add tests for -e, -l, -w, -W.
2026-06-12 17:17:43 +01:00
Pádraig Brady a52fcef903 tests: pr: add checks for +... parameter handling
* tests/pr/options.sh: Ad a new test.
* tests/local.mk: Reference new test.
Addresses https://bugs.gnu.org/81225
2026-06-12 13:24:42 +01:00
Collin Funk 41b205b6d7 tests: ptx: check that invalid regular expressions are diagnosed
* tests/ptx/ptx.pl (@Tests): Add two test test cases.
2026-06-11 21:42:47 -07:00
Collin Funk ce0f4f68df tests: join: add another -e test case
* tests/join/join.pl (@tv): Add a test case.
2026-06-11 00:14:21 -07:00
Pádraig Brady 0a1a7f9022 cut: fix NUL termination of multi-byte field delimiter
* src/cut.c (delim_bytes): Add a spare byte so a maximum-length
multi-byte delimiter stays NUL terminated for the strstr needle in
find_field_delim.  Note in 9.11 this buffer was larger (16 bytes)
and so didn't not have a buffer over-read issue.
(main): Ensure DELIM_BYTES is NUL terminated after each --delimeter.
Also explicitly writing the NUL allows for better testing by
triggering overflow issues in default builds, if the buffer
is not sized correctly.
* NEWS: Mention the bug fix.
* tests/cut/cut.pl: Add test cases.
Reported at https://github.com/coreutils/coreutils/pull/286
2026-06-10 13:50:04 +01:00
aizu-m 4ade9cf77f unexpand: fix heap overflow when a wide blank overshoots a tab stop
* NEWS: Mention the bug fix.
* src/unexpand.c (unexpand): Check if the column is greater or equal to
the next_tab_column.
* tests/unexpand/mb.sh: Add a test case.
https://github.com/coreutils/coreutils/pull/285
Copyright-paperwork-exempt: Yes
2026-06-09 18:20:39 -07:00
Sylvestre Ledru a04250cf3b tests: ls: cover two-line --time-style format assignment
* tests/ls/ls-time.sh: Check that with a "FORMAT1 NEWLINE FORMAT2"
  --time-style, FORMAT1 is used for non-recent (old) files and FORMAT2
  for recent files.
  Identified here: https://github.com/uutils/coreutils/issues/12676
Closes https://github.com/coreutils/coreutils/pull/281
2026-06-09 14:38:15 +01:00
Sylvestre Ledru c8ce189cbd tests: split: reject excessively large suffix lengths
* tests/split/suffix-length.sh: Ensure that a pathologically large
-a/--suffix-length value fails gracefully rather than crashing or
hanging.
https://github.com/uutils/coreutils/pull/12609
Closes https://github.com/coreutils/coreutils/pull/282
2026-06-09 14:22:09 +01:00
Sylvestre Ledru 5008d5d112 tests: sort: cover punctuation weight in locale collation
* tests/sort/sort-locale.sh: In a UTF-8 locale '-' carries a minimal
(shifted) weight, so 'file1' sorts before 'file-2' even though '-'
precedes '1' in the C/byte order.  This is the opposite of the C locale
result, so it also exercises the differs-from-C path.
Identified here: https://github.com/uutils/coreutils/pull/12677
Closes https://github.com/coreutils/coreutils/pull/283
2026-06-09 14:08:02 +01:00
Sylvestre Ledru e75940f675 tests: date: check date-string parsing corner cases
* tests/date/date.pl: Add tests covering a leading day-of-week name,
out-of-range zone minutes, two timezone tokens, a bare sign operand,
a trailing token after an @epoch operand, operand quoting in
diagnostics, and a '+N unit' suffix following a complete time.
* tests/date/date-tz.sh: Add tests covering daylight-saving gap,
and overlap local times.
Closes https://github.com/coreutils/coreutils/pull/284
2026-06-09 13:42:00 +01:00
Collin Funk 3ae92d6fd2 tests: install: check the behavior when strip is terminated by a signal
* tests/install/strip-program.sh: Add the test case.
2026-06-08 21:57:39 -07:00
Collin Funk 65ce1bd641 tests: dircolors: add another test case for TERM
* tests/misc/dircolors.pl (@Tests): Add a test case.
2026-06-08 21:18:57 -07:00
Collin Funk dd777fe89f tests: install: check the behavior when the source is the destination
* tests/install/basic-1.sh: Add the test case.
2026-06-07 22:39:43 -07:00
Collin Funk e583cae508 tests: fold: test that --width=0 produces an error
* tests/fold/fold.pl ($limits): New variable.
(@Tests): Add the test case.
2026-06-07 19:45:30 -07:00