You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
od --traditional offset/label arithmetic overflows on a near-maximal offset (overflow-checks panic; release wraps) #13225
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 uncheckedu64 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 0xffffffffffffffffthread 'main' panicked at src/uu/od/src/input_offset.rs:40:31:attempt to add with overflownote: 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.pubfnincrease_position(&mutself,n:u64){self.byte_pos += n;// uncheckedifletSome(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.
Activity
od: wrap the offset instead of overflowing on a large --traditional l…
od: fix overflow panic in --traditional label accumulator