Skip to content

od: diagnose too-large -j, -N and -S values - #16732

Open
binhvq wants to merge 3 commits into
uutils:mainfrom
binhvq:od-too-large-jns
Open

binhvq wants to merge 3 commits into
uutils:mainfrom
binhvq:od-too-large-jns

Conversation

@binhvq

@binhvq binhvq commented Nov 20, 2026

Copy link
Copy Markdown
Contributor

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

Comment thread src/uu/od/src/parse_nrofbytes.rs Outdated
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));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you use e.kind() == &IntErrorKind::PosOverflow instead of checking the digits by hand?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread tests/by-util/test_od.rs Outdated
.fails_with_code(1)
.stderr_only(format!("od: {flag} argument '{TOO_LARGE}' too large\n"));
}
for value in ["0x10000000000000000", "18446744073709551616"] {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you please also check that 9223372036854775807 is still accepted? and an octal value past u64

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@codspeed

codspeed Bot commented Nov 21, 2026

Copy link
Copy Markdown
Contributor

Merging this PR will regress 1 benchmark

2 warnings, 1 note

⚠️ 121 benchmarks are dominated by system calls

System calls cannot be simulated consistently and are left out of the measure. The reported value understates the real cost. Switch to the Walltime instrument to measure them.

Learn more about system calls

See affected benchmarks

⚠️ 3 benchmarks with a significant change ran on different hardware

Their base and head results were measured on machines with a different CPU, core count or memory, so the changes might not come from the code. Run base and head on the same runner type.

Learn more about Macro Runners

See affected benchmarks

ℹ️ 1 benchmark has no flamegraph

The flamegraph wasn't generated: most of the time was spent in runtime internals, which would leave nothing useful to analyze.

See affected benchmarks

⚡ 2 improved benchmarks
❌ 1 regressed benchmark
✅ 410 untouched benchmarks
⏩ 70 skipped benchmarks1

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Mode Benchmark BASE HEAD Efficiency
❌ CPU Simulation ls_recursive_deep_tree[(200, 2)] 2.8 ms 2.9 ms -3.79%
⚡ Memory cp_recursive_deep_tree[(120, 4)] 699.2 KB 581.2 KB +20.31%
⚡ CPU Simulation ls_recursive_mixed_tree 2.5 ms 2.4 ms +3.45%

Tip

Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.


Comparing binhvq:od-too-large-jns (15ec9ea) with main (f21dd53)2

Open in CodSpeed

Footnotes

  1. 70 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩

  2. No successful run was found on main (558c250) during the generation of this report, so f21dd53 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report. ↩

@xtqqczze

Copy link
Copy Markdown
Collaborator

needs to be rebased for codspeed

@binhvq

binhvq commented Nov 21, 2026

Copy link
Copy Markdown
Contributor Author

Merged main into the branch so CodSpeed has a current base.

Comment thread tests/by-util/test_od.rs
.stderr_only(format!("od: {flag} argument '{TOO_LARGE}' too large\n"));
}
for value in ["0x10000000000000000", "18446744073709551616"] {
for value in [

@xtqqczze xtqqczze Nov 21, 2026 •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please use rstest cases

@xtqqczze

Copy link
Copy Markdown
Collaborator

no merge commits please, and please squash for a clean branch history

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

od: -j/-N/-S values above i64::MAX are not reported as too large

3 participants