mirror of
https://git.savannah.gnu.org/git/coreutils.git
synced 2026-11-17 18:02:09 +03:00
tests: numfmt: add checks for overflowing unit sizes
* tests/numfmt/numfmt.pl (@Tests): Add unit-11 and unit-12, ensuring a --to-unit/--from-unit whose suffix multiplication overflows uintmax_t is rejected with "invalid unit size" rather than being wrapped or crashing. Link: https://github.com/uutils/coreutils/pull/13484 Link: https://github.com/coreutils/coreutils/pull/326
This commit is contained in:
1 parent
47f57665d5
commit
48c4c15e4e
1 file changed
+9
@@ -115,6 +115,15 @@ my @Tests =
|
||||
['unit-10', '--to-unit=0 1',
|
||||
{ERR => "$prog: invalid unit size: '0'\n"},
|
||||
{EXIT => '1'}],
|
||||
# Ensure a unit size whose suffix multiplication overflows uintmax_t
|
||||
# is rejected. 18014398509481984Ki is 2^54.
|
||||
# Multiplying by Ki (2^10) overflows to UINTMAX_MAX + 1.
|
||||
['unit-11', '--to-unit=18014398509481984Ki 1000',
|
||||
{ERR => "$prog: invalid unit size: '18014398509481984Ki'\n"},
|
||||
{EXIT => '1'}],
|
||||
['unit-12', '--from-unit='.$limits->{UINTMAX_MAX}.'K 1',
|
||||
{ERR => "$prog: invalid unit size: '$limits->{UINTMAX_MAX}K'\n"},
|
||||
{EXIT => '1'}],
|
||||
|
||||
# Test Suffix logic
|
||||
['suf-1', '4000', {OUT=>'4000'}],
|
||||
|
||||
Reference in new issue
Block a user