fix(dd): reject oversized block sizes instead of crashing#12887
Open
miniex wants to merge 1 commit into
Open
Conversation
A huge ibs=/obs=/bs=/cbs= value used to panic (multiply overflow) or abort (failed allocation). Reject block sizes >= i64::MAX at parse time like GNU, and allocate the output buffer with try_reserve. Fixes uutils#12844, uutils#12847
|
GNU testsuite comparison: |
sylvestre
reviewed
Jun 15, 2026
| settings: &settings, | ||
| }; | ||
| let mut output = BufferedOutput::new(inner); | ||
| let mut output = BufferedOutput::new(inner).unwrap(); |
There was a problem hiding this comment.
unwrap will introduce panics again that is i see, which we want suspose to prevent we spent hours to search for panics, so please do'nt use panic functions handle the Result
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hello, I'm a developer from Korea, so sorry in advance if my English is a bit awkward 🙏
A very large block-size operand (
ibs=,obs=,bs=,cbs=) makesddcrash instead of erroring out like GNU does:>= i64::MAXpanics withattempt to multiply with overflowwhile the buffer size is computed (bug(dd): when ibs= is a very large number it panics #12844)obsaborts the whole process while allocating the output buffer (bug(dd): when obs= is a very large number it panics #12847)What I did:
>= i64::MAXat parse time, with the same "Value too large for defined data type" message as GNUsaturating_mulfor the lcm buffer-size computation so it can't overflowtry_reserve, so a too-largeobsfails gracefully instead of abortingI also added regression tests.
cargo fmt,clippy(-D warnings) and theddtest suite all pass on my machine (x86_64 Linux).Fixes #12844
Fixes #12847