* src/pr.c (char_to_clump): Use ckd_add() and report integer overflow.
* tests/pr/options.sh: Add a test case.
* NEWS: Mention the bug fix.
Fixes https://bugs.gnu.org/81393
standard output is fully buffered, e.g., when redirected to a file.
[bug introduced in coreutils-9.10]
+ 'pr' now exits gracefully upon exceeding internal accounting limits,
+ like when processing large tab stops.
+ [This bug was present in "the beginning".]
+
'shred' no longer blocks when opening a FIFO that has no readers.
[This bug was present in "the beginning".]
else if (width < 0 && input_position <= -width)
input_position = 0;
else
- input_position += width;
+ {
+ if (ckd_add (&input_position, input_position, width))
+ integer_overflow ();
+ }
return chars;
}
>exp || framework_failure_
compare exp err || fail=1
+# Ensure we exit gracefully upon internal overflow limits
+# Tag as expensive as it uses little mem, but about 10s on a 2020 class machine.
+if { test "$RUN_VERY_EXPENSIVE_TESTS" = yes ||
+ test "$RUN_EXPENSIVE_TESTS" = yes; } &&
+ test "$INT_MAX" = 2147483647; then # restrict to usual 32 bit limits
+ head -c1M /dev/zero | tr '\0' '\t' |
+ returns_ 1 pr -t -e$(($INT_MAX/(1024*1024) + 1)) 2>err >/dev/null || fail=1
+ printf '%s\n' "pr: integer overflow" > exp || framework_failure_
+ compare exp err || fail=1
+fi
+
Exit $fail