Commit Graph
2036 Commits
Author SHA1 Message Date
Collin Funk 89a7510051 head: fix two bugs when eliding bytes from a pipe
* 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.
2026-11-16 15:47:15 -08:00
Collin Funk 2b0f8f9d82 ln: fix -srf creating a symbolic link to itself
* 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.
2026-11-16 15:38:34 -08:00
Ismail Ramzi 3b77964c3c pr: avoid a heap overflow with a very wide line number
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
2026-11-15 12:32:36 +00:00
Pádraig Brady 57d6cc458b cp,mv,install: fix infinite loop with --backup=t and unreadable dirs
* 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.
2026-11-15 12:30:40 +00:00
Collin Funk 1444825d52 ln: use atomic rename to make backups
* 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.
2026-11-15 02:21:37 -08:00
Collin Funk 35492ca115 install: don't follow symlinks when setting the mode
* 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.
2026-11-14 15:10:37 -08:00
Pádraig Brady a80621e6aa chmod: fix silent skipping when /proc is unavailable
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.
2026-11-14 20:26:42 +00:00
Pádraig Brady fa578f1da4 chmod: fix skipped items with -R --dereference --preserve-root
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.
2026-11-14 18:57:55 +00:00
Collin FunkandPádraig Brady 94b24850da timeout: handle child processes that use PTRACE_TRACEME
* 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>
2026-11-13 20:12:25 -08:00
Collin Funk 247c2a04f8 install: use file descriptor relative operations for security contexts
* 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.
2026-11-13 19:26:32 -08:00
Collin Funk 20e9ffd8c5 split: fix two bugs occurring with filters that exit early
* 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.
2026-11-13 18:47:23 -08:00
Collin Funk 3f8a5b5470 df: don't open non-directory operands
* 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.
2026-11-13 18:27:05 -08:00
Joao Matos 2d02d08215 csplit: don't truncate the input when an output file is the input
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.
2026-11-12 22:37:13 -08:00
Pádraig Brady 6b7abe6572 tail: ensure bounded operation when appending to input
`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.
2026-11-10 21:04:45 +00:00
Pádraig Brady afa7bdf79d maint: adjust NEWS ordering/formatting
* NEWS: Fix alphabetic ordering, and quoting of command names.
2026-11-10 12:52:08 +00:00
Pádraig Brady f66f9b1146 cut,expand,fold,unexpand: fix handling of multi-byte with short reads
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.
2026-11-10 12:52:08 +00:00
Pádraig Brady 4f20df5a92 cut: improve responsiveness for trailing bytes in multi-byte locales
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.
2026-11-10 12:52:08 +00:00
Collin Funk 9704f18343 split: don't stop reading if a single filter stops accepting input
* 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.
2026-11-09 16:09:49 -08:00
Collin Funk 20faee4d42 split: don't create more than N input files with -n l/N and short lines
* 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.
2026-11-08 12:36:23 -08:00
Collin Funk 79063df078 sort: don't share compressed temp files for the same input when merging
* 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.
2026-11-08 12:01:22 -08:00
Collin Funk 5b86ff66eb cp,mv,install: exit with status 1 when creating a hole fails
* 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.
2026-11-08 11:00:49 -08:00
Collin Funk 8121423eda pr: fix an infinite loop with a page of leading tabs and small columns
* 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.
2026-11-07 11:48:00 -08: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
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
Pádraig Brady bc177b4275 chroot: fix supplemental group lookup with --userspec=UID
* 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.
2026-11-06 23:54:53 +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
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 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 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 13e26e5e0f mkfifo,mknod: avoid a race with a specified mode
* 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.
2026-10-31 23:03:27 -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
Collin Funk e10de8ddd0 chcon: print the entire file name in errors setting the context
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.
2026-10-30 15:58:04 -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
Collin Funk d58314f178 pr: fix a crash when reading more than INT_MAX bytes for a single page
* 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.
2026-10-29 16:29:14 -07: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
Collin Funk 7a3fdd3185 cp,mv: print the destination file name when setting xattrs fails
* 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.
2026-10-27 23:25:59 -07:00
Collin Funk 7dc6f9c0d8 install: use the user's umask when invoking 'strip'
* 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.
2026-10-27 20:35:10 -07:00
Collin Funk c242899118 nl: don't treat empty lines as headers with an empty -d argument
* 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.
2026-10-27 18:16:03 -07:00
Pádraig Brady 266abf3fd2 cksum: fix --check ambiguities in base64 detection
* 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.
2026-10-27 23:15:56 +00:00
Pádraig Brady 119cabc8a1 cksum: support mixed reversed format checksum files
* 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.
2026-10-27 23:15:56 +00:00
Pádraig Brady 1ca499910a cksum: fix incorrectly accepting lengths on fixed length algorithms
* src/cksum.c (split_3): Restrict to length variable digest types.
* tests/cksum/cksum-c.sh: Add test cases.
* NEWS: Mention the fix.

Discovered by Anthropic's OSS Scanner, as bug ANT-2026-ATAXIQDM.
2026-10-27 23:15:56 +00:00