od `--traditional` offset/label arithmetic overflows on a near-maximal offset (overflow-checks panic; release wraps)
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 24.1k
- Forks
- 2k
- Avg merge
- 1d 5h
- Merged PRs (30d)
- 365
Description
In --traditional mode, od accepts an explicit pseudo-address label. A label near u64::MAX makes the offset accumulator overflow: InputOffset::increase_position adds the bytes-read n to the running position/label with unchecked u64 arithmetic (self.byte_pos += n, self.label = Some(l + n)). With a label of 0xffffffffffffffff, the very first read overflows that add.
It panics only under overflow-checks (debug builds, or a release build compiled with -C overflow-checks=on).
$ printf '0123456789ABCDEF' | ./target/debug/od --traditional - 0 0xffffffffffffffff
thread 'main' panicked at src/uu/od/src/input_offset.rs:40:31:
attempt to add with overflow
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
$ echo $?
101
Root cause
// src/uu/od/src/input_offset.rs
/// Increase `byte_pos` and `label` if a label is used.
pub fn increase_position(&mut self, n: u64) {
self.byte_pos += n; // unchecked
if let Some(l) = self.label {
self.label = Some(l + n); // <- input_offset.rs:40:31, overflows when l ≈ u64::MAX
}
}
label comes directly from the --traditional pseudo-address argument (0xffffffffffffffff here = u64::MAX), and byte_pos from the (also user-influenceable) starting offset. Adding the per-read byte count n with plain +/+= overflows.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the near-maximal-label command from the issue, then read src/uu/od/src/input_offset.rs and inspect InputOffset::increase_position. Trace how --traditional parses and uses the label, and check existing od tests for overflow behavior. Done means the supplied input no longer panics when the label or offset approaches u64::MAX, with behavior covered by a regression test.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- cli
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 58/100