With -t/-T or a page length too short for headers, GNU pr does not pad
the final page or emit page separators (extremities=false in pr.c). This
fixes output like 'pr -t -n70000' now matching GNU byte for byte.
* uucore: fix parse_size overflow on a large `%` size
The `%` (percent-of-physical-memory) branch of `Parser::parse` computed
`(number / 100) * total` as an unchecked `u128` multiply. A percentage
that fits in a `u128` but whose product with the total physical memory
does not would overflow, panicking with "attempt to multiply with
overflow" under `-C overflow-checks` (exit 134) instead of reporting a
parse error:
$ du --block-size=9223372036854775808000000000000% /tmp
thread 'main' panicked at parse_size.rs:258:33:
attempt to multiply with overflow
Because `parse_size` is shared code, the panic was reachable from every
util that accepts a size: du, sort, df, ls, split, stdbuf, od, shred,
dd, head and tail.
Use `checked_mul` and return `ParseSizeError::SizeTooBig` on overflow,
matching how the non-percent path already handles the same condition a
few lines below. Callers therefore get the behaviour they already have
for other too-large sizes such as `1Y`: utils that report an error keep
reporting one, and utils using `parse_u64_max`/`parse_u128_max` clamp to
the maximum, as GNU does.
Fixes#13736
* tests(sort): cover percent-size overflow in --buffer-size
Adds an integration test exercising the fix in uucore::parse_size for a
percentage value whose product with total physical memory overflows u128.
The expected behavior is an error rather than a panic or silent wrap.
This isn't a statement for or against AI agents - people are using them
here either way. It is only there to guide them better, so the project
rules (no GNU code, tests required, short PR descriptions, read the docs)
are actually followed.
See https://github.com/uutils/coreutils/blob/main/CONTRIBUTING.md#ai-policy