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.
* src/pr.c: Move the pointer initialization later,
when we know the indexes will be valid. The UMR was
already known, as per the removed comment,
but not triggered until recent indexing changes.
Reported by Bruno Haible.
* tests/env/env.sh: Avoid calling "sh" with a modified argv[0],
as e.g. with busybox providing sh, it will fail with "applet not found".
Reported by Bruno Haible.
This was seen on Centos 7 at least with bash 4.2.46.
* tests/timeout/timeout.sh: Ensure the shell doesn't incorrectly
optimize itself away when there are traps in place.
Reported by Bruno Haible.
* tests/ls/line-separator.sh: Skip on systems that treat
U+2028 (LINE SEPARATOR), and U+2029 (PARAGRAPH SEPARATOR)
as printable. Also since we're requiring our printf now,
use that to decouple the test from the particular shell-escape
quoting form used.
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.
* tests/chown/cannot-access.sh: New test. Ensure chown and chgrp
report "cannot access" for a missing operand, a trailing slash on a
non-directory and a missing file in a directory, and "cannot
dereference" only for a dangling symlink.
* tests/local.mk (all_tests): Reference the new test.
https://github.com/uutils/coreutils/pull/15868
Link: https://github.com/coreutils/coreutils/pull/449
dash 0.5.13 to 0.5.13.5 at least has a variable expansion bug:
https://bugzilla.redhat.com/2568651
This was seen on Fedora 44 and there is no upstream dash
release with a fix yet.
* init.cfg (bad_unicode): Avoid the dash issue, by comparing
the variable expansion and skipping upon mismatch.
* tests/du/block-size.sh: Add explicit checks for expansion
on values with high bit set.
* tests/paste/multi-byte.sh: Likewise.
* gnulib: Update to get commit 8b4da9a18f (attribute: Provide access to
gcc's access attribute., 2026-11-05).
* src/system.h (ptr_align): Use ATTRIBUTE_ACCESS_NONE.
* 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.