Skip to content

od: wrap offset instead of overflowing on a large --traditional label - #13896

Open
AlejandroCoronadoN wants to merge 1 commit into
uutils:mainfrom
AlejandroCoronadoN:fix-od-traditional-offset-overflow
Open

od: wrap offset instead of overflowing on a large --traditional label#13896
AlejandroCoronadoN wants to merge 1 commit into
uutils:mainfrom
AlejandroCoronadoN:fix-od-traditional-offset-overflow

Conversation

@AlejandroCoronadoN

Copy link
Copy Markdown

Summary

In --traditional mode, od accepts a pseudo-address label. A label near u64::MAX
overflows the offset accumulator on the first read:

$ printf '0123456789ABCDEF' | od --traditional - 0 0xffffffffffffffff
thread 'main' panicked at src/uu/od/src/input_offset.rs: attempt to add with overflow
$ echo $?
101

(under -C overflow-checks).

Root cause

InputOffset::increase_position used unchecked u64 arithmetic
(self.byte_pos += n, self.label = Some(l + n)).

Fix

Use wrapping_add. The byte offset and label are fixed-width addresses, so wrapping
(as GNU od does) is the correct behavior and cannot overflow. Adds a unit test.

Fixes #13225.

…abel

InputOffset::increase_position used unchecked u64 arithmetic, so a
--traditional label near u64::MAX aborted on the first read. Byte offset and
label are fixed-width addresses, so wrap them like GNU od. Adds a unit test.

Fixes uutils#13225.
@codspeed-hq

codspeed-hq Bot commented Aug 12, 2026

Copy link
Copy Markdown

Merging this PR will degrade performance by 18.61%

⚠️ Different runtime environments detected

Some benchmarks with significant performance changes were compared across different runtime environments,
which may affect the accuracy of the results.

Open the report in CodSpeed to investigate

❌ 1 regressed benchmark
✅ 346 untouched benchmarks
⏩ 46 skipped benchmarks1

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Mode Benchmark BASE HEAD Efficiency
Simulation df_with_path 573.7 µs 704.9 µs -18.61%

Tip

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


Comparing AlejandroCoronadoN:fix-od-traditional-offset-overflow (573a3a8) with main (822aa83)

Open in CodSpeed

Footnotes

  1. 46 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.

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 --traditional offset/label arithmetic overflows on a near-maximal offset (overflow-checks panic; release wraps)

1 participant