1
0
mirror of git://git.sv.gnu.org/coreutils.git synced 2026-02-10 09:21:58 +02:00
Commit Graph

31173 Commits

Author SHA1 Message Date
Pádraig Brady
33bc44e1ba copy: protect against infinite loop due to pathological race
Consider:

1. In infer_scantype():
    - SEEK_DATA returns 0
      - hole punched at 0
    - SEEK_HOLE returns 0 (now a hole)
    - Cache scan_inference->hole_start = 0
2. In lseek_copy():
      - data written at 0
    - ext_start = 0, use cached hole_start = 0
    - ext_len = 0
    - now loop doesn't progress

* src/copy-file-data.c (lseek_copy): Apply a more defensive check
to ensure we only use the cached offsets in SCAN_INFERENCE once.
This protects against an infinite loop where an extent (at SRC_POS)
flip flops between data and hole extent while infer_scantype()
and lseek_copy() are inspecting it.  I.e. ensure we use SEEK_HOLE
to progress the copy.
2026-01-06 20:41:15 +00:00
Pádraig Brady
c43f517e2a tests: cp: fix always skipped nfs-removal-race.sh
* tests/cp/nfs-removal-race.sh: This test was invalid since v8.32
as we now use fstatat() rather than stat().  Also since commit
v9.0-66-ge2daa8f79 we leverage the errno from open(O_DIRECTORY)
to avoid a stat, so pass --no-target-directory to ensure fstatat()
is called.
Discussed in https://github.com/coreutils/coreutils/pull/161
2026-01-06 20:35:44 +00:00
Christopher Illarionova
1afe4109f2 tests: cp: support glibc 2.33+ in nfs-removal-race test
glibc 2.33 removed __xstat, making stat() a direct symbol. This test
previously only intercepted __xstat, causing it to skip on modern glibc
with 'LD_PRELOAD was ineffective'.

Changes:
- Intercept both __xstat (glibc < 2.33) and stat (glibc >= 2.33)
- Only mark 'preloaded' when stat is called on destination 'd',
  ensuring the test verifies cp actually stats the destination
2026-01-06 18:55:47 +00:00
Pádraig Brady
a3ae4123f9 doc: tr: warn about shell quoting [:classes:]
* src/tr.c (usage): Warn about avoiding shell globbing.
* doc/coreutils.texi (character arrays): Likewise.
Suggested by Daniel Dallos.
2026-01-06 18:41:00 +00:00
Pádraig Brady
7531d3a205 ptx: implement -t to change default width to 100
Align the -t implementation with the Heirloom project.

* src/ptx.c (usage): Describe -t, and also mention
the default width is 72 when not used.
* doc/coreutils.texi (ptx invocation): Likewise.
(main): Override the default width if -t is specified.
* tests/ptx/ptx.pl: Add test cases.
* NEWS: Mention the change in behavior.
2026-01-05 23:37:49 +00:00
Christopher Illarionova
e1994cd9ac tests: stty: add require_controlling_input_terminal_ to bad-speed test
The bad-speed test runs 'stty ispeed 9600' without a --file argument,
which requires a controlling terminal. Without it, stty fails early with
'Inappropriate ioctl for device' before reaching cfsetispeed, causing
the test to skip with a misleading 'LD_PRELOAD interception failed'
message.

* tests/stty/bad-speed.sh: Add require_controlling_input_terminal_
to match the other stty tests (stty.sh, stty-pairs.sh, stty-row-col.sh,
stty-invalid.sh) which all require a controlling terminal.
From https://github.com/coreutils/coreutils/pull/160
2026-01-05 17:20:54 +00:00
Collin Funk
2e0c328a3b maint: mknod: reduce variable scope
* src/mknod.c (main): Declare variables where they are used instead of
at the start of a block. Prefer signed integers to unsigned integers.
2026-01-04 13:47:01 -08:00
Collin Funk
e4e40b7df6 maint: mkfifo: reduce variable scope
* src/mkfifo.c (main): Declare variables where they are used instead of
at the start of a block.
2026-01-04 13:46:41 -08:00
Pádraig Brady
bd528f9234 copy: fix possible infinite loop with SEEK_HOLE
Commit v9.8-95-g4c0cf3864 intended to initialize
ext_start to src_pos, as was described at:
https://lists.gnu.org/r/coreutils/2025-11/msg00035.html
However ipos was inadvertently used, which is only
valid the first time through the loop.

* src/copy-file-data.c (lseek_copy): Use scan_inference->hole_start
only with the initial offset passed to lseek_copy().
* NEWS: Mention the bug fix.
Reported at https://github.com/coreutils/coreutils/issues/159
2026-01-04 20:20:04 +00:00
Pádraig Brady
71e0be29f1 tests: chmod: ensure failure upon partial success
* tests/chmod/partial-fail.sh: Add new test.
* tests/local.mk: Reference new test.
Discussed at https://github.com/uutils/coreutils/issues/9790
2026-01-03 14:45:07 +00:00
oech3
1170bc9489 tests: split: ensure directories not replaced
* tests/split/split-io-err.sh: Add a test case.
From https://github.com/coreutils/coreutils/pull/158
2026-01-03 14:27:55 +00:00
Collin Funk
ae5ceffc13 doc: NEWS: mention du performance improvement on the Lustre file system
Reported by Tim Day <timday@amazon.com> in
<https://bugs.gnu.org/80106>.

* NEWS: Mention the improvement after gnulib commit 578b8d7dc5.
2026-01-02 19:29:11 -08:00
Collin Funk
3424ae3efa build: update gnulib submodule to latest
* bootstrap: Update using './bootstrap --bootstrap-sync'.
* tests/sample-test: Adjust to use the single most recent year.
2026-01-01 20:50:59 -08:00
Collin Funk
bdb6148fdc maint: prefer c_isblank to an equivalent macro
* src/cksum.c (ISWHITE): Remove macro.
(bsd_split_3, algorithm_from_tag, split_3): Use c_isblank instead of
ISWHITE.
2026-01-01 19:10:30 -08:00
Collin Funk
9cdeeea7c2 tests: df: don't depend on bash
* tests/df/no-mtab-status-masked-proc.sh: Invoke $SHELL instead of
'bash'.
2026-01-01 19:07:51 -08:00
Collin Funk
73d3a49f45 maint: run 'make update-copyright' 2026-01-01 10:56:16 -08:00
Sylvestre Ledru
cd08aa2056 tests: mv: check broken symlink cross-filesystem move
Identified here:
<https://github.com/uutils/coreutils/issues/8586>

* tests/mv/mv-special-2.sh: Add the check.
2026-01-01 13:43:15 +00:00
oech3
92a93c445b tests: df: hide /proc without using LD_PRELOAD
* tests/df/no-mtab-status-masked-proc.sh: A new test similar
to no-mtab-status.sh but should work with static builds.
* tests/local.mk: Reference the new test.
https://github.com/coreutils/coreutils/pull/156
2026-01-01 13:18:51 +00:00
oech3
3f0ab90497 tests: add LD_PRELOAD free alternative for nproc-quota.sh
* tests/nproc/nproc-quota-systemd.sh: Add a new root test.
* tests/local.mk: Reference the new test.
2026-01-01 12:24:50 +00:00
oech3
6a2a781efd tests: extend csplit-io-err.sh for directory
* tests/csplit/csplit-io-err.sh: Add a test case
to ensure a directory is _not_ replaced.
2026-01-01 11:50:07 +00:00
Sylvestre Ledru
75e314a11a tests: du: check -l (--count-links) without -a flag
Identified here:
<https://github.com/uutils/coreutils/issues/9871>

* tests/du/hard-link.sh: Add the check.
2025-12-31 00:01:51 +00:00
Collin Funk
d3f0c72902 tests: env: check that real-time signals can be ignored
* tests/env/env-signal-handler.sh: Test that --ignore-signal with no
options also ignores real-time signals. Test that real-time signals can
be ignored by explicitly listing them.
2025-12-29 21:26:22 -08:00
Collin Funk
d45598f237 tests: kill: check that real-time signals are listed
* tests/misc/kill.sh: Call getlimits_. Check for RTMIN and RTMAX in the
output of 'kill -l' if the system defines SIGRTMIN and SIGRTMAX.
2025-12-27 21:48:42 -08:00
Collin Funk
7e1b4f76d3 getlimits: print SIGRTMIN and SIGRTMAX
* src/getlimits.c (SIGRTMIN): Define to zero if signal.h does not define
this constant.
(SIGRTMAX): Define to SIGRTMIN - 1 if signal.h does not define this
constant.
(main): Print SIGRTMIN and SIGRTMAX.
2025-12-27 17:03:39 -08:00
Collin Funk
1902c97d67 maint: commit-msg: add 'getlimits' as a supported tag
* scripts/git-hooks/commit-msg (@valid): Add getlimits.
2025-12-27 17:03:39 -08:00
oech3
0ffd9a1812 tests: split: verify operation in the presence of I/O errors
* tests/split/split-io-err.sh: A new test to verify that with I/O
errors, we leave existing files but don't continue.
* tests/local.mk: Reference the new test.
2025-12-27 16:55:53 +00:00
Pádraig Brady
e10205bab2 tests: check I/O error handling with /dev/full and closed pipes
* tests/misc/io-errors.sh: Verify that all commands diagnose write
errors, and handle a closed pipe appropriately.
* tests/local.mk: Reference the new test.
2025-12-27 16:55:48 +00:00
Pádraig Brady
6382388da8 sort: fix SIGPIPE handling
* src/sort.c (main): Don't override handler for SIGPIPE
(which we did since commit v9.9-34-ge63131b32),
since we've explicit handling for SIGPIPE.
Also move ignoring of SIGPIPE until after
--help and --version are processed.
2025-12-27 16:27:43 +00:00
oech3
1b467784fb tests: consolidate csplit-io-err tests
* tests/csplit/csplit-io-err.sh: Replace this LD_PRELOAD test with...
* tests/csplit/csplit-io-err-2.sh: This more general test,
that leverages /dev/full.
* tests/local.mk: Remove tests/csplit/csplit-io-err-2.sh.
2025-12-27 12:48:57 +00:00
oech3
60f48bbda6 tests: csplit: check writing to /dev/full
* tests/csplit/csplit-io-err-2.sh: Add a new test.
* tests/local.mk: Reference new test.
2025-12-26 14:59:39 +00:00
Collin Funk
b12593d124 dd: don't continue copying when ftruncate fails using seek= and of=
* src/dd.c (main): Reduce the scope of exit_status. Exit immediately if
ftruncate fails.
* tests/dd/fail-ftruncate-fstat.sh: New test.
* tests/local.mk (all_tests): Add the new test.
* NEWS: Mention the bug fix.
2025-12-25 15:16:57 -08:00
Pádraig Brady
7c1bc64d38 doc: document the date(1) bug with empty format directives
* NEWS: Mention the bug fix.
2025-12-25 14:30:59 +00:00
Pádraig Brady
78c8447a98 build: update gnulib to latest 2025-12-25 14:25:58 +00:00
Collin Funk
18405cb51a tests: date: improve locale tests
* tests/date/date-locale-hour.sh: Test that the default format of 10
random supported locales is the same as 'locale date_fmt'.
2025-12-24 18:41:34 -08:00
Pádraig Brady
95044cb5ea tests: avoid false failure due to ulimit on aarch64
* tests/cut/cut-huge-range.sh: Add an extra 1MiB headroom,
which was seen with aarch64.
Reported at https://bugzilla.redhat.com/2424302
2025-12-22 17:12:48 +00:00
Pádraig Brady
e34734cdf9 maint: tests/cut/cut-huge-range.sh: remove stale comment
* tests/cut/cut-huge-range.sh: expr supports bignums,
so remove stale comment relating to previous non expr adjustment.
2025-12-22 15:24:07 +00:00
Pádraig Brady
955dfdafa2 numfmt: fix dropped custom suffix when failing to parse
* src/numfmt.c (process_suffixed_number): Restore custom suffix
upon failure to parse number.
* tests/numfmt/numfmt.pl: Add test cases.
* NEWS: Mention the bug fix.
Fixes https://bugs.debian.org/1094581
2025-12-22 13:17:37 +00:00
Collin Funk
1313c24056 maint: prefer enums over macros for sources used for multiple programs
* src/chown.h (enum chown_modes): New type.
(CHOWN_CHOWN, CHOWN_CHGRP): Define as an enum instead of a macro.
* src/chown-chgrp.c (chown_mode): Use "enum chown_modes" instead of
"int".
* src/chown-chown.c (chown_mode): Likewise.
* src/ls.h (enum ls_modes): New type.
(LS_LS, LS_MULTI_COL, LS_LONG_FORMAT): Define as an enum instead of a
macro.
* src/ls-dir.c (ls_mode): Use "enum ls_modes" instead of "int".
* src/ls-ls.c (ls_mode): Likewise.
* src/ls-vdir.c (ls_mode): Likewise.
* src/uname.h (enum uname_modes): New type.
(UNAME_UNAME, UNAME_ARCH): Define as an enum instead of a macro.
* src/uname-arch.c (uname_mode): Use "enum uname_modes" instead of
"int".
* src/uname-uname.c (uname_mode): Likewise.
2025-12-20 17:25:32 -08:00
Collin Funk
d7aaa001d9 doc: prefer UTF-8 characters in texinfo sources
* doc/coreutils.texi (Introduction): Use ç instead of @,{c}.
(Character arrays): Use ö instead of @"o. Use Ł instead of @L{}.
(Formatting file timestamps): Use ä instead of @"a.
2025-12-20 13:27:07 -08:00
Pádraig Brady
3a07cefae0 doc: ls: fix recent typo for -F option in texinfo
* doc/coreutils.texi (ls invocation): Add a missing hyphen
that was inadvertently dropped in the recent adjustments.
2025-12-20 20:09:37 +00:00
Pádraig Brady
8f4a0095a0 tests: runcon: avoid false success
* tests/runcon/runcon-compute.sh: Ensure runcon runs,
since the main test is a negative one.
2025-12-20 13:17:12 +00:00
Pádraig Brady
7be8402e1e doc: split,tac: document $TMPDIR usage
Following commit v9.3-92-g1b86b70dd
$TMPDIR is part of the interface and an important behavioral
characteristic of a command, which should be documented.

* doc/coreutils.texi (split invocation): Mention $TMPDIR is honored.
(tac invocation): Likewise.
* src/split.c (usage): Likewise.
* src/tac.c (usage): Likewise.
2025-12-19 00:09:58 +00:00
Collin Funk
a2c3896b51 doc: tee: prefer cksum in examples
* doc/coreutils.texi (tee invocation): Use 'cksum' with '-a sha2' and
'-a sha3' instead of md5sum and sha1sum in examples.
2025-12-16 22:15:26 -08:00
Pádraig Brady
9a1bd362d2 tests: mv: check moving named sockets is supported
* tests/mv/mv-special-2.sh: Use python to create a named socket,
and ensure it's copied across file systems.
2025-12-16 11:33:38 +00:00
Collin Funk
45071c85b5 tests: date: add another locale test case
On a GNU/Linux system, we have the following:

    $ LC_ALL=en_US.UTF-8 date -u -d 1:00
    Sun Dec 14 01:00:00 AM UTC 2025
    $ LC_ALL=en_US.UTF-8 locale date_fmt
    %a %b %e %r %Z %Y
    $ LC_ALL=en_US.UTF-8 locale t_fmt_ampm
    %I:%M:%S %p

    $ LC_ALL=nl_NL.UTF-8 date -u -d 1:00
    zo 14 dec 2025  1:00:00 UTC
    $ LC_ALL=nl_NL.UTF-8 locale date_fmt
    %a %e %b %Y %k:%M:%S %Z

We respect the locales preference for a leading zero or leading space in
single digit hours.

* tests/date/date-locale-hour.sh: Check that the locales preference for
leading zeros or spaces in single digit hours is used.
2025-12-15 15:54:00 -08:00
Pádraig Brady
f4dca9ca03 tests: mv: check traversed fifos copy correctly
* tests/mv/mv-special-1.sh: Add a case also for fifos
encountered when traversing.
2025-12-15 15:30:43 +00:00
Pádraig Brady
9ad870131d tests: mv: add timeout protection when moving fifos
* tests/mv/mv-special-1.sh: Implementations could potentially hang
interacting with fifos, so wrap with timeout.
2025-12-15 13:54:25 +00:00
Collin Funk
3b809382b8 doc: dd: document the behavior of conv flags on multibyte characters
* doc/coreutils.texi (dd invocation): Document the behavior of 'dd' on
multibyte characters and some unspecified behavior that will be
documented in a future POSIX release [1].

[1] https://austingroupbugs.net/view.php?id=1959
2025-12-13 18:55:00 -08:00
Collin Funk
cfd78d0877 tests: ls: use a larger file descriptor limit
OpenBSD and Alpine Linux /bin/sh cannot handle a file descriptor limit
of 7.

* tests/ls/recursive.sh: Create 30 directories and use a file descriptor
limit of 20. Don't check the output since we have coverage for that
elsewhere.
Reported by Bruno Haible.
2025-12-13 18:37:18 -08:00
Pádraig Brady
cd52292221 build: reduce size of multi-call binary by reusing cksum logic
Map md5sum and sha{1,224,256,385,512} to use cksum logic,
which selects appropriate behavior at runtime, rather than
separate binaries for each closely related utility.

$ size src/coreutils  # before
   text	   data	    bss	    dec	    hex	filename
1349509	   6812	 619312	1975633	 1e2551	src/coreutils
$ size src/coreutils  # after
   text	   data	    bss	    dec	    hex	filename
1306933	   6748	 619152	1932833	 1d7e21	src/coreutils

* build-aux/gen-single-binary.sh: Map sha*sum to use cksum.c
* src/cksum.c: Adjust to behave more like sha*sum,
when the algorithm to something other than "crc".
* src/cksum.h: Expose the cksum_algorithm global and enum.
* src/coreutils-md5sum.c: Set cksum_algorithm and call cksum logic.
* src/coreutils-sha1sum.c: Likewise.
* src/coreutils-sha224sum.c Likewise.
* src/coreutils-sha256sum.c Likewise.
* src/coreutils-sha384sum.c Likewise.
* src/coreutils-sha512sum.c Likewise.
* NEWS: Mention the improvement.
2025-12-13 17:18:47 +00:00