mirror of
https://git.savannah.gnu.org/git/coreutils.git
synced 2026-11-17 18:02:09 +03:00
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
This commit is contained in:
1 parent
83545af2a8
commit
171b53a95d
3 files changed
+15
-3
No files matched your search
@@ -100,6 +100,11 @@ GNU coreutils NEWS -*- outline -*-
|
||||
od now exits gracefully when offsets overflow integer limits.
|
||||
[This bug was present in "the beginning".]
|
||||
|
||||
od now continues to process inputs upon read error.
|
||||
Previously it would stop after the block being read, and then output
|
||||
a block of uninitialized or previously output data.
|
||||
[bug introduced in coreutils-9.4]
|
||||
|
||||
'pr' no longer reads past its internal buffer and crashes when it reads more
|
||||
than INT_MAX bytes of column data for a single page.
|
||||
[This bug was present in "the beginning".]
|
||||
|
||||
@@ -1537,7 +1537,7 @@ dump (void)
|
||||
|
||||
intmax_t current_offset = n_bytes_to_skip;
|
||||
|
||||
do
|
||||
while (true)
|
||||
{
|
||||
intmax_t needed_bound
|
||||
= end_offset < 0 ? INTMAX_MAX : end_offset - current_offset;
|
||||
@@ -1554,11 +1554,10 @@ dump (void)
|
||||
write_block (current_offset, n_bytes_read,
|
||||
block[!idx], block[idx]);
|
||||
if (ferror (stdout))
|
||||
ok = false;
|
||||
write_error ();
|
||||
current_offset = offset_add (current_offset, n_bytes_read);
|
||||
idx = !idx;
|
||||
}
|
||||
while (ok);
|
||||
|
||||
if (n_bytes_read > 0)
|
||||
{
|
||||
|
||||
@@ -115,6 +115,14 @@ my @Tests =
|
||||
{OUT=>"0000001 hello\n0000007 world\n"}],
|
||||
['S-Ao', '-Ao -S3', {IN=>"\001hello\000world\000ab\000"},
|
||||
{OUT=>"0000001 hello\n0000007 world\n"}],
|
||||
|
||||
# Ensure that all remaining input is output following an input error.
|
||||
# From coreutils-9.4 through coreutils-9.12, od would stop after the
|
||||
# block being read, and then output an uninitialized or stale block.
|
||||
['read-err-1', '-An -c -w4', {IN=>{g=>'a'}}, 'missing',
|
||||
{IN=>{h=>'bcdefghij'}}, {EXIT=>1},
|
||||
{OUT=>" a b c d\n e f g h\n i j\n"},
|
||||
{ERR=>"$prog: missing: $limits->{ENOENT}\n"}],
|
||||
);
|
||||
|
||||
push @Tests,
|
||||
|
||||
Reference in new issue
Block a user