ptx: fix infinite loop with -G and a narrow output width
With GNU extensions disabled, before_max_width can go negative, and
define_all_fields then loops forever trying to shrink the before field
to a width narrower than empty:
$ printf 'qux\n' | src/ptx -G -w2
[hangs]
Commit v6.12-96-g773be9eca added a clamp for this, but placed it in
the GNU-extensions branch only. Move it after that if/else so that
both branches are covered.
* src/ptx.c (fix_output_parameters): Clamp before_max_width for both
the GNU and non-GNU cases.
* tests/ptx/ptx-overrun.sh: Add a test case.
* NEWS: Mention the bug fix.
Fixes https://bugs.gnu.org/81507
* tests/expr/expr-multibyte.pl: Add 'cu' prefixed cases running in
C.UTF-8, which names no language but has a UTF-8 codeset, ensuring
length, index, substr and match still operate on characters there.
Skip them where that locale is unavailable.
tests: sort: check byte-wise ordering in the C.UTF-8 locale
* tests/sort/sort-locale.sh: C.UTF-8 has a UTF-8 codeset but the
collation rules of C, so add a case ensuring the ordering there stays
byte-wise rather than following the linguistic rules exercised for
en_US.iso8859-1 and fr_FR.UTF-8 above.
The quoting characters and the printability of a multibyte character are
selected by the locale's codeset, not by its language, but no test
covered a locale that has a UTF-8 codeset and no language.
* tests/ls/quoting-utf8.sh: Check that in C.UTF-8 the locale/clocale
styles use the Unicode quotes and that literal/escape/shell-escape pass
a multibyte character through unaltered, whereas the plain C locale
octal-escapes it or replaces it with '?'.
tests: prefer require_inotify_supported_ to file system check
* tests/tail/inotify-rotate-resources.sh: Use require_inotify_supported_
instead of require_local_dir_ and the recently added check for
overlayfs.
Suggested by Pádraig Brady.
* NEWS: Mention the bug fix.
* cfg.mk (exclude_file_name_regexp--sc_prohibit_test_minus_ao): Exclude
NEWS.
* src/test.c (term): Treat '-a' and '-o' as strings instead of expecting
them to be valid unary operators.
* tests/test/test.pl: Add some test cases.
* tests/test/test-diag.pl: Also test the diagnostics with '-a arg'.
ls: fix a small mem leak when CLI args have errors
$ valgrind --quiet --leak-check=full --show-leak-kinds=definite \
src/ls --hyperlink=always foo bar
ls: cannot access 'foo': No such file or directory
ls: cannot access 'bar': No such file or directory
32 bytes in 1 blocks are definitely lost in loss record 3 of 7
at malloc (vg_replace_malloc.c:447)
by canonicalize_filename_mode_stk (canonicalize.c:450)
by canonicalize_filename_mode (canonicalize.c:471)
by gobble_file.constprop.0 (ls.c:3392)
by main (ls.c:1765)
* src/ls.c (gobble_file): Call free_ent() before returning.
chcon,chgrp,chmod,chown,du,ls: ignore missing files while traversing
* src/fts-missing.h: Add helper routines to determine
if an FTS entry is skippable. I.e., that is traversed
and not specified on the command line.
* src/chcon.c (process_file): Setup to ignore skippable files.
(change_file_context): Ignore missing files if appropriate.
* src/chmod.c (process_file): Setup to ignore skippable files.
Ignore missing files if appropriate.
(mode_changed): Ignore missing files if appropriate.
* src/chown-core.c (change_file_owner): Setup to ignore skippable files.
Ignore missing files if appropriate.
* src/du.c (process_file): Likewise.
* src/ls.c (print_dir): Ignore missing files if appropriate.
(get_link_name): Likewise.
(gobble_file): Likewise. Also handle the dangling symlink case.
* src/system.h (ignorable_traversal_errno): Match ENOENT for missing
files.
* tests/chcon/traversal-missing.sh: A new test.
* tests/misc/traversal-missing.sh: Likewise.
* tests/local.mk: Reference the new tests.
* NEWS: Mention the bug fix.
Fixes https://bugs.gnu.org/81444
doc: printf: detail exactly which escapes are supported
* doc/coreutils.texi (echo invocation): Parameterize the escape list.
(printf invocation): Remove the C escape reference as it mentions
\' which we don't support, and doesn't mention \e which we do support
(and GCC also does). Instead directly present the escape list
as done for the echo command, adjusted accordingly.
build: reduce size of multi-call binary by reusing true logic
Map 'false' to reuse logic from 'true', instead of creating separate
binaries for each utility.
$ size src/coreutils-prev
text data bss dec hex filename 1476092 7348 21919363675376 3814f0 src/coreutils-prev
$ size src/coreutils
text data bss dec hex filename 1474612 7348 21919683673928 380f48 src/coreutils
* src/local.mk (noinst_HEADERS): Add src/true.h.
(src_false_LDADD): Organize with the rest of the reused programs. Use
$(src_true_LDADD) instead of $(LDADD).
(src_true_SOURCES, src_false_SOURCES): New variables.
* build-aux/gen-single-binary.sh (override_single): Map 'false' to
'true'.
* src/false.c: Remove file.
* po/POTFILES.in: Remove src/false.c.
* cfg.mk (_src): Match src/true-false.c and src/true-true.c.
* src/coreutils-false.c: New file.
* src/true-false.c: Likewise.
* src/true-true.c: Likewise.
* src/true.h: Likewise.
* src/true.c: Include true.h.
(EXIT_STATUS): Always define the macro to use the value of the TRUE_MODE
variable.
(PROGRAM_NAME): Likewise.
* NEWS: Mention the improvement.
build: reduce size of multi-call binary by reusing test logic
Map the '[' command to which selects appropriate behavior at runtime,
rather than separate binaries for each closely related utility.
$ size src/coreutils-prev
text data bss dec hex filename 1485188 7348 21919683684504 383898 src/coreutils-prev
$ size src/coreutils
text data bss dec hex filename 1476092 7348 21919363675376 3814f0 src/coreutils
* src/local.mk (noinst_HEADERS): Add src/test.h.
(src___SOURCES): Remove src/lbracket.c. Add src/test.c and
src/test-lbracket.c.
(src_test_SOURCES): New variable.
(src/coreutils.h): Adjust the function name to be
single_binary_main_lbracket instead of single_binary_main__.
* build-aux/gen-single-binary.sh: Likewise. Map '[' to 'test'.
(override_single): Adjust the file name to be coreutils-lbracket.c
instead of coreutils-_.c.
* src/lbracket.c: Remove file.
* cfg.mk (_src): Don't match src/lbracket.c in the regular
expression. Match src/test-lbracket.c and src/test-test.c.
* src/coreutils-lbracket.c: New file.
* src/test-lbracket.c: Likewise.
* src/test-test.c: Likewise.
* src/test.h: Likewise.
* src/test.c: Include test.h.
(LBRACKET): Remove macro.
(PROGRAM_NAME): Use the variable TEST_MODE to determine the program
name.
(main): Use the variable TEST_MODE instead of the LBRACKET macro to
implement behavior specific to '['.
* NEWS: Mention the improvement.
* tests/rm/empty-immutable-skip.sh: Use cleanup_() to
remove the immutable attribute, so that false failures
or stale files do not result from e.g. a killed test run.
"install -C" (--compare) has always called chown/chmod on the
destination even after determining that copying was unnecessary,
ever since --compare was added in commit v7.0-182-gdac5f12c6.
need_copy() already verifies that the destination's mode, owner, and
group match (and, with --preserve-context, that the SELinux context
matches too) before skipping the copy, so re-applying them is
redundant, and can needlessly fail on a destination that cannot be
chown/chmod'd even though nothing would actually change, e.g. one
marked immutable with chattr +i.
* src/install.c (install_file_in_file): Skip metadata updates
if we already skipped the data, as previous checks ensure
that the metadata is already as required.
* tests/install/install-C-immutable.sh: Add a test.
(based on tests/rm/empty-immutable-skip.sh).
* tests/local.mk: Reference the new test.
* NEWS: Mention the improvement.
The github mirror is a common interaction point
for issues and pull requests, so reference it in README and HACKING.
Also update the current size of the repo to be more accurate.
doc: install: mention -p may lose some of -C speed benefits
* doc/coreutils.texi (install invocation): Mention that
--preserve-timestamps may lose some of the speed advantages of -C,
due to needing to update timestamps for each build.
tests: dd: ensure nocache flag does not fail with pipes
* tests/dd/nocache.sh: Whether fadvise() is called (uutils)
or avoided (GNU), ensure there is no failure when nocache
is only the ancillary operation being requested.
oech3 [Thu, 4 Jun 2026 11:15:40 +0000 (20:15 +0900)]
tests: cat: extract checks for distinct read/write errors
* tests/cat/splice.sh: Move read/error distinction test to ...
* tests/cat/cat-distinct-err.sh: ... here, and augment.
* tests/local.mk: Reference the new file.
Guanqiang Han [Tue, 7 Jul 2026 14:58:43 +0000 (22:58 +0800)]
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
$ 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.
* doc/coreutils.texi (touch invocation): Use lower case for @var{}.
This is ambiguous for MM and mm, but these are not ambiguous
from the context, so shouldn't cause confusion.
Paul Eggert [Thu, 9 Jul 2026 23:35:32 +0000 (16:35 -0700)]
touch: improve -d documentation
* doc/coreutils.texi (touch invocation):
Describe -d behavior for HH:MM:60 (Bug#81331), as it seems that a
future version of POSIX will bless GNU touch here.
Be clearer about POSIX vs GNU extensions with -d.
* doc/coreutils.texi (mv invocation): Copy most of the -n
description from the cp --no-clobber description.
* src/mv.c (usage): Likewise. Note this explicitly deprectates
the mv -n option as like cp the exit code varies across platforms.
Solaris 11 was seen to silently fail, while Linux/FreeBSD succeed.
Fixes https://bugs.gnu.org/81377
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
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
* 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.
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.
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
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.
Pádraig Brady [Thu, 25 Jun 2026 20:03:00 +0000 (22:03 +0200)]
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.
Sylvestre Ledru [Sat, 27 Jun 2026 09:02:51 +0000 (11:02 +0200)]
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.
Sylvestre Ledru [Sun, 28 Jun 2026 09:27:19 +0000 (11:27 +0200)]
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
Sylvestre Ledru [Sun, 28 Jun 2026 12:27:46 +0000 (14:27 +0200)]
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.
Sylvestre Ledru [Thu, 25 Jun 2026 19:14:00 +0000 (21:14 +0200)]
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.
* 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.
Collin Funk [Tue, 23 Jun 2026 02:36:47 +0000 (19:36 -0700)]
cksum: remove the ability to use AF_ALG
* gnulib: Update to latest gnulib for commit e191cc8118 (crypto/af_alg:
Deprecate., 2026-06-22).
* NEWS: Mention the removal of the --with-linux-crypto configure option.
* doc/coreutils.texi (Hardware Acceleration): Remove the reference to
--with-linux-crypto and the Linux kernel cryptographic API.
Paul Eggert [Sat, 20 Jun 2026 19:14:55 +0000 (12:14 -0700)]
dd: work around Linux kernel CLOCK_MONOTONIC bug
Problem reported by Sick Pigs (bug#81269).
Ordinarily we’d say “fix the kernel or the hardware”,
but this bug seems widespread and unlikely to be fixed any time soon,
and the workaround is not a lot of trouble.
* src/dd.c (real_start_time): New static var.
(getrealxtime): New static function.
(print_xfer_stats): Use the max of elapsed monotonic and elapsed
real time.
aizu-m [Fri, 19 Jun 2026 06:53:03 +0000 (12:23 +0530)]
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.
Pádraig Brady [Sat, 13 Jun 2026 14:50:53 +0000 (23:50 +0900)]
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
Collin Funk [Sun, 14 Jun 2026 02:34:51 +0000 (19:34 -0700)]
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.
Pádraig Brady [Wed, 10 Jun 2026 06:02:40 +0000 (11:32 +0530)]
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
aizu-m [Tue, 9 Jun 2026 07:07:06 +0000 (12:37 +0530)]
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
Sylvestre Ledru [Sun, 7 Jun 2026 09:43:43 +0000 (11:43 +0200)]
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
Sylvestre Ledru [Sun, 7 Jun 2026 09:54:40 +0000 (11:54 +0200)]
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
Sylvestre Ledru [Sun, 7 Jun 2026 09:58:49 +0000 (11:58 +0200)]
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
* 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
Collin Funk [Sun, 7 Jun 2026 23:43:50 +0000 (16:43 -0700)]
nohup: port to mingw
* bootstrap.conf (gnulib_modules): Add execvp which as a different
prototype on Windows along with other issues mentioned in the Gnulib
manual.
* src/nohup.c (main): Check if SIGHUP is defined.
Sylvestre Ledru [Sat, 6 Jun 2026 06:11:52 +0000 (08:11 +0200)]
tests: ls: also check a trailing '/.' dereferences a symlink arg
* tests/ls/symlink-slash.sh: A symlink-to-directory argument written as
'symlink/.' denotes the directory itself, just like a trailing slash, so
'ls -l symlink/.' must list the directory contents rather than show the
symlink.
See https://github.com/uutils/coreutils/issues/7873
and https://github.com/uutils/coreutils/issues/6467
https://github.com/coreutils/coreutils/pull/280
Pádraig Brady [Wed, 3 Jun 2026 15:31:39 +0000 (16:31 +0100)]
stat: change default quoting from shell-escape-always to shell-escape
This should not affect programatic parsing, because if you have to parse
the shell style, then the same logic will parse unescaped output.
This is a better default now that --terse uses quoted format by default,
and also the default output format quotes file names by default.
* src/stat.c (getenv_quoting_style): Change the default.