* src/head.c (elide_tail_bytes_pipe): Don't set REM to BUFSIZ when the
REMAINDER is zero. Don't assume the input is longer than the given
number of bytes.
* tests/head/head-elide-tail.pl ($HEAD_TAIL_PIPE_BYTECOUNT_THRESHOLD)
($MULTIPLE, $FRACTION): New variables.
(@Tests): Add a few test cases for the bugs.
* NEWS: Mention the bug fixes.
Discovered by Anthropic's OSS Scanner, as bug ANT-2026-BMLRFV62.
* src/ln.c (do_link): Don't set SOURCE to REL_SOURCE before the backup
checks.
* tests/ln/relative.sh: Add two test cases.
* NEWS: Mention the bug fix.
Discovered by Anthropic's OSS Scanner, as bug ANT-2026-ET9AU19B.
With -n and truncated lines, add_line_number() added NUMBER_WIDTH to
INPUT_POSITION without checking for overflow. A tab at the start of a
line followed by a line number width near INT_MAX would wrap
INPUT_POSITION negative, and with -e the next tab would then be
expanded by more than the tab width, writing past the end of CLUMP_BUFF.
E.g., printf '\t\t\n' | pr -t -e -W2147483647 -n:2147483643
wrote 12 bytes into an 8 byte buffer.
* src/pr.c (add_line_number): Use ckd_add when advancing INPUT_POSITION.
(init_parameters): Likewise when computing NUMBER_WIDTH,
which overflowed with -n:2147483647.
* tests/pr/options.sh: Add test cases.
* NEWS: Mention the bug fix.
Link: https://github.com/coreutils/coreutils/pull/458
* gnulib: Update to get the fix.
* tests/cp/backup-unreadable.sh: Add a new test case.
* tests/local.mk: Reference the new test.
* NEWS: Mention the bug fix.
* src/ln.c (do_link): Use backup_file_rename which uses renameat2 on
platforms that support it.
* NEWS: Mention the bug fix. Remove mentions of 'ln' from the 'cp',
'mv', and 'install' changes in release 8.28 from Commit 0d74ac470 (copy:
make backup files more reliably, 2017-07-30).
* cfg.mk (old_NEWS_hash): Update using 'make update-NEWS-hash'.
Discovered by Anthropic's OSS Scanner, as bug ANT-2026-D7OXM969.
* src/copy.h (struct cp_options): Add the owner and group fields.
* src/cp.c (cp_option_init): Initialize them to -1.
* src/mv.c (cp_option_init): Likewise.
* src/install.c (cp_option_init): Likewise.
(change_attributes): Use lchmodat instead of chmodat. Only set the
attributes here if 'strip' is used.
(change_timestamps): Use AT_SYMLINK_NOFOLLOW when calling utimensat.
(main): If --strip is not in use, have copy set the mode and ownership
for us with the file descriptor it has open.
* src/copy.c (copy_reg): Don't use fclonefileat if we have to set the
mode, since it would require a subsequent open. If the owner and/or
group are given in the options, set the ownership.
(copy_internal): Omit permissions if set_mod in the options is set.
* NEWS: Mention the bug fix.
Discovered by Anthropic's OSS Scanner, as bug ANT-2026-HJARXJNW.
Discovered by Calif.io, as bug ANT-2026-J82F5KHS.
You can get ENOTSUP due to the system not supporting chmod(symlink),
but you can also get ENOTSUP on any file type if the system needs
/proc to emulate AT_SYMLINK_NOFOLLOW and /proc is not available.
Before this fix we had the problematic "Silent skip" in these cases:
Build glibc Runtime Linux With /proc Without /proc
============= ============ =================== ====================
≤ 2.31 Any gnulib emulation Racy fallback
2.32–2.38 Any glibc emulation Silent skip
≥ 2.39 < 6.6 glibc emulation Silent skip
≥ 2.39 ≥ 6.6 Native fchmodat2 Native fchmodat2
After this change (and the preceding gnulib change), we have:
Build glibc Runtime Linux With /proc Without /proc
============= ============ =================== ====================
≤ 2.38 Any gnulib emulation Racy fallback
≥ 2.39 < 6.6 glibc emulation Diagnose ENOTSUP
≥ 2.39 ≥ 6.6 Native fchmodat2 Native fchmodat2
The above tables assume /proc is available at ./configure time.
Other cases like musl < 1.2.4 are not considered,
but there should at least be no silent ignoring of issues
once reported by the underlying libc.
* src/chmod.c (process_file): Check we're operating on a symlink
if we get ENOTSUP, and only ignore the error in that case.
* tests/chmod/symlink-enotsup.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-PSCKLNL1.
Fix skipped processing of items after a symlink to '/'.
* src/chmod.c (process_file): Only skip with directory
visited in pre-order.
* tests/chmod/symlinks.sh: Add a test case (skipped if root).
* NEWS: Mention the bug fix.
Discovered by Anthropic's OSS Scanner, as bug ANT-2026-HWDZFHEJ.
* m4/jm-macros.m4 (coreutils_MACROS): Check for ptrace.
* src/timeout.c [HAVE_PTRACE && (__linux__ || __ANDROID__)]: Include
sys/ptrace.h.
(resume_command): New function.
(main): Call it if the monitored command has been stopped.
* tests/timeout/ptrace-traceme.sh: New file.
* tests/local.mk (all_tests): Add the new test case.
* NEWS: Mention the improvement.
Discovered by Anthropic's OSS Scanner, as bug ANT-2026-AKDIHN0Y.
Co-authored-by: Pádraig Brady <P@draigBrady.com>
* src/install.c: Include selinux-at.h.
(need_copy): Expect a directory file descriptor and relative name
argument, instead of a file name. Use them when getting the security
context of the destination.
(setdefaultfilecon): Expect a directory file descriptor and relative
name argument. Use it when setting the security context of the
destination.
(copy_file): Adjust call to need_copy.
(change_attributes): Adjust call to setdefaultfilecon.
* gnulib: Update for commit dd5b313c3f (selinux-at: Define functions
that don't perform context translation., 2026-11-10).
* NEWS: Mention the bug fix.
Discovered by Anthropic's OSS Scanner, as bug ANT-2026-XB6SGSHL.
* src/split.c (bytes_split): Don't lseek when the offset is already at
the correct position from reading. Don't add 1 to TO_WRITE.
* tests/split/filter.sh: Add two test cases.
* NEWS: Mention the bug fixes.
Discovered by Anthropic's OSS Scanner, as bug ANT-2026-D5DVHK7A.
* src/df.c (automount_stat_err): Use O_DIRECTORY when opening operands.
Fall back to stat if open fails with ENOTDIR.
* tests/df/open.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-Z5SPLRCM.
csplit opened each output file with fopen "w", which truncates it,
before reading the part of the input that goes into it. When an
output file name (xx00, xx01, ...) refers to the input file, the part
of the input not yet read was lost: all of it for the first output
file, and for later ones whatever was not yet buffered, usually
silently, with exit status 0:
$ seq 300000 > xx01 && csplit xx01 2 && wc -c xx01
8188 xx01 # was 1988895 bytes
If a later pattern then failed, csplit removed the output files it
had created, the input among them.
Instead, as split does, open the output without O_TRUNC, compare it
with the input, and fail with "would overwrite input; aborting"
before anything is written. The input is left intact, and the
output files created so far are removed, unless -k is given.
* src/csplit.c: Don't include stdio--.h.
(in_stat_buf): New static variable.
(main): Set it after opening the input.
(create_output_file): Open the output without O_TRUNC, and fail if it
is the input file; truncate it otherwise.
* NEWS: Mention the bug fix.
`tail -n2 in >> in` already operated in a bounded manner,
so this makes tailing from the start with `tail -n+2 in >> in`
bounded also, operating only on the original file contents
and not increasing the size of 'in' forever.
Note this bounded operation does not apply with -f.
* src/tail.c (remaining_input): A new helper to return
the limit of the original file when output is the same file.
(tail_bytes): Use the new limit from remaining_input().
(tail_lines): Likewise.
* tests/tail/append-to-input.sh: Adjust accordingly.
Note this test was failing on Alpine due to its
different buffering behavior. We're now consistent
over all file sizes and buffering behaviour in this case.
* NEWS: Mention the improvement.
Test failure reported by Bruno Haible.
This change is performance neutral as tested with:
$ yes $(yes eeeaae | head -n10K | paste -s -d,) | head -n10K > ll.in
$ hyperfine src/cut{,.orig}' -f10 -w ll.in >/dev/null'
* gl/lib/mbbuf.h (mbbuf_fill): Repeat the mbbuf_topup(), i.e. the read()
if the previous run didn't read enough. Note we add the explicit
common case short-circuit to avoid a 20% regression
for the test case above, with GCC 16.2 with -O3 -flto.
* tests/cut/mb-short-read.sh: A new test file.
* tests/local.mk: Reference the new test.
* NEWS: Mention the bug fix.
Discovered by Anthropic's OSS Scanner, as bug ANT-2026-JSCMJCN2.
This change is performance neutral as tested with:
$ yes | head -n10M > sl.in
$ yes $(yes éééááé | head -n9 | paste -s -d,) | head -n1M > mb.in
$ hyperfine src/cut{,.orig}' -c1 sl.in >/dev/null'
$ hyperfine src/cut{,.orig}' -f1 -w mb.in >/dev/null'
* src/cut.c (skip_buffered_line): A new refactored helper.
* src/cut.c (scan_mb_line_end): Use help, and also call mbbuf_avail()
to process remaining bytes before topup.
(cut_characters_mode): Likewise. Note the topup is done implicitly
in the following mbbuf_get_char().
* NEWS: Mention the bug fix.
Discovered by Anthropic's OSS Scanner, as bug ANT-2026-VRMLC6DR.
* src/split.c (of_t): Add the done member.
(lines_rr): Set the done member for the file if the filter has an
ignorable error. Don't attempt subsequent writes if the done member for
the file is set.
* tests/split/filter.sh: Add a test case.
* NEWS: Mention the bug fix.
Discovered by Anthropic's OSS Scanner, as bug ANT-2026-NO8YC6GS.
* src/split.c (lines_chunk_split): Make sure CHUNK_NO does not exceed N.
* tests/split/l-chunk.sh: Add a test case without --elide-empty-files
and with it.
* NEWS: Mention the bug fix.
Discovered by Anthropic's OSS Scanner, as bug ANT-2026-ZDDBFXXM.
* src/sort.c (sortlines): Don't share compressed temporary files when
the same input is given multiple times.
* tests/sort/sort-compress-hang.sh: Add a test case that would
previously hang.
* NEWS: Mention the bug fix.
Discovered by Anthropic's OSS Scanner, as bug ANT-2026-MYSN7JAW.
* src/copy-file-data.c (sparse_copy): Return -1 when create_hole fails.
* tests/cp/fail-create-hole.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-C18OTMQ2.
* src/pr.c: Continue processing if the line is truncated instead of
returning early. Return after handling headers, line numbers, etc., but
before printing the truncated clump.
* tests/pr/inf-loop.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-TMZPQ2AH.
* 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.
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.
* src/chroot.c (main): Copy pwd->pw_name as it can be overwritten.
* NEWS: Mention the fix.
Discovered by Anthropic's OSS Scanner, as bug ANT-2026-C8RRA4R8.
* 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.
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
* 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.
* 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.
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.
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.
* 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.
* 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.
* 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.
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
* 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>
* src/mkfifo.c: Include fcntl--.h.
(main): When a mode is specified, open a file descriptor to its parent
and use it to create the FIFO and set its mode.
* src/mknod.c: Include fcntl--.h.
(main): When a mode is specified, open a file descriptor to its parent
and use it to create the special file and set its mode.
* NEWS: Mention the bug fix.
Discovered by Anthropic's OSS Scanner, as bug ANT-2026-ACVILIMZ.
* 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
* 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.
Previously, only the basenames were printed, leading to ambiguity when
multiple directories had a file with the same name. E.g., here is the
old output:
$ mkdir -p a/{b,c}
$ touch a/{b,c}/d
$ strace -o /dev/null -e inject=lsetxattr:error=EIO \
chcon -R -u root a
chcon: failed to change context of 'd' to '...': ...
chcon: failed to change context of 'b' to '...': ...
chcon: failed to change context of 'd' to '...': ...
chcon: failed to change context of 'c' to '...': ...
chcon: failed to change context of 'a' to '...': ...
Here is the new output:
$ strace -o /dev/null -e inject=lsetxattr:error=EIO \
src/chcon -R -u root a
chcon: failed to change context of 'a/b/d' to '...': ...
chcon: failed to change context of 'a/b' to '...': ...
chcon: failed to change context of 'a/c/d' to '...': ...
chcon: failed to change context of 'a/c' to '...': ...
chcon: failed to change context of 'a' to '...': ...
This also aligns the output with other programs, e.g., 'chown':
$ strace -o /dev/null -e inject=chown,fchown,fchownat:error=EIO \
chown -R root a
chown: changing ownership of 'a/b/d': ...
chown: changing ownership of 'a/b': ...
chown: changing ownership of 'a/c/d': ...
chown: changing ownership of 'a/c': ...
chown: changing ownership of 'a': ...
* src/chcon.c (change_file_context): Add an argument for the full file
name. Use it in error messages.
(process_file): Pass the full file name from the FTSENT.
* NEWS: Mention the bug fix.
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
* src/pr.c (buff_current): Define as an idx_t instead of an int.
(line_vector): Define as an array of idx_t elements instead of int.
(store_colum): Define a variable used to set buff_current as an idx_t.
* NEWS: Mention the bug fix.
Discovered by Anthropic's OSS Scanner, as bug ANT-2026-C1YW9FO0.
* 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.
* src/copy.c (copy_attr_quote): Return a xstrdup'd copy of the result of
quoteaf, so that slot 0 of quotearg can be overwritten by a subsequent
call without overwriting the previously quoted string.
(copy_attr_free): Free the string. Remove MAYBE_UNUSED from the string.
* tests/cp/xattr.sh: Add a getlimits_ and uses_strace_ invocation.
(block_setxattr): New function. Use it to check the error/warning
message when setting extended attributes on the destination fails.
* NEWS: Mention the bug fix.
Discovered by Anthropic's OSS Scanner, as bug ANT-2026-BPGHOHDX.
* src/install.c (initial_umask): New variable.
(strip): Set the umask to initial_umask before invoking 'strip' and then
reset it to zero after the child is created.
(main): Save the initial umask when setting it to zero.
* tests/install/strip-program.sh: Add a few invocations to test the
behavior.
* NEWS: Mention the bug fix.
Discovered by Anthropic's OSS Scanner, as bug ANT-2026-39LQ2UOD.
* src/nl.c (check_section): Add a check for a zero section delimiter
length.
* tests/nl/nl.sh: Add a test case.
* NEWS: Mention the bug fix.
Discovered by Anthropic's OSS Scanner, as bug ANT-2026-PDYYNTYZ.
* src/cksum (valid_digits): Use '=' to disambiguate hex and base64.
(split_3): Likewise.
(digest_check): Likewise.
* tests/cksum/cksum-base64-untagged.sh: Add a test case.
* NEWS: Mention the fix.
* src/cksum.c (digest_check): Reset the detection flag per file.
* tests/cksum/cksum-c.sh: Add a test case.
* tests/cksum/md5sum-bsd.sh: Likwise.
* NEWS: Mention the fix.