Repository navigation
Conversation
| let digits = &s[start..len]; | ||
| // A number made of valid digits that does not fit u64 is too large, | ||
| // not invalid: GNU accepts it as a number and reports the overflow. | ||
| let all_digits = !digits.is_empty() && digits.chars().all(|c| c.is_digit(radix)); |
There was a problem hiding this comment.
could you use e.kind() == &IntErrorKind::PosOverflow instead of checking the digits by hand?
There was a problem hiding this comment.
Done — now uses e.kind() == &IntErrorKind::PosOverflow, same as uucore's parse_size. Added tests: 9223372036854775807 is still accepted, octal past u64 is too large. Both pass.
| .fails_with_code(1) | ||
| .stderr_only(format!("od: {flag} argument '{TOO_LARGE}' too large\n")); | ||
| } | ||
| for value in ["0x10000000000000000", "18446744073709551616"] { |
There was a problem hiding this comment.
could you please also check that 9223372036854775807 is still accepted? and an octal value past u64
There was a problem hiding this comment.
Checked with the built binary: od -j 9223372036854775807 is still accepted (it errors at skip-past-end, not too-large), octal 02000000000000000000000 reports too large. That case is now in test_od_invalid_bytes; 99 od tests pass.
Merging this PR will regress 1 benchmark2 warnings, 1 note
Warning Please fix the performance issues or acknowledge them on CodSpeed. Performance Changes
Tip Investigate this regression by commenting Comparing Footnotes
|
|
needs to be rebased for codspeed |
|
Merged main into the branch so CodSpeed has a current base. |
| .stderr_only(format!("od: {flag} argument '{TOO_LARGE}' too large\n")); | ||
| } | ||
| for value in ["0x10000000000000000", "18446744073709551616"] { | ||
| for value in [ |
There was a problem hiding this comment.
please use rstest cases
|
no merge commits please, and please squash for a clean branch history |
Values above i64::MAX were accepted: -j reported a skip error at runtime, -N dumped the whole input and -S printed nothing, while GNU rejects the value at parse time. A hex number past u64 was even reported as invalid instead of too large.
Reject the value in parse_bytes_option and turn a u64 overflow of a valid hex or octal number into the too-large error, echoing the flag the user actually gave.
Fixes #16731