Repository navigation
[FIX] Reject malformed --buffersize, --sendto and --service values - #2393
Merged
Merged
Conversation
--buffersize went through a lenient atol(): "abc", "12x" or an empty value silently became 0, which is then clamped to an 8-byte file buffer, and "3G" overflowed i32. It is now validated by clap: a byte count with an optional K, M or G suffix, as documented, that fits in an int. --sendto parsed the port with unwrap(), so "host:abc", "host:" or an out-of-range port aborted the process (SIGABRT). It is now validated by clap through the same split used to assign the address and port. --service parsed each service number with unwrap(), so a number too large for usize aborted. It now reports the existing "Invalid service number" error instead. Valid values parse exactly as before; --help is unchanged.
5 of 7 tasks
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.
In raising this pull request, I confirm the following (please check boxes):
Reason for this PR:
Sanity check:
Repro instructions:
On master, with any input file:
ccextractor input.ts --buffersize abc(or12x,3G) runs with exit 0 — the value silently becomes 0 and is clamped to an 8-byte file buffer.ccextractor input.ts --sendto 127.0.0.1:abc(orhost:,[::1]:abc) aborts with SIGABRT (exit 134):panicked at src/parser.rs:1404.ccextractor input.ts --service 99999999999999999999999aborts with SIGABRT:panicked at src/parser.rs:363.Same class as #2374/#2386: option values that were parsed after clap with a lenient helper or
unwrap().--buffersize: validated by clap — a byte count with an optional K/M/G suffix (as documented), fitting anint. Values below 8 are still clamped to 8. Replaces the lenientatol().--sendto: validated by clap via the samesplit_sendto_address()used to assign the address and port (host,host:port,[ipv6],[ipv6]:port, as before).--service: a service number too large forusizenow gets the existing "Invalid service number" error instead of a panic.--buffersize=abc/12x/ emptyinvalid value …: expected a size in bytes, optionally suffixed with K, M or G--buffersize=3G/99999999999size is too large--sendto host:abc/host:/[::1]:abcinvalid port '…'--service 99999999999999999999999Invalid service number (…)Verified: new tests fail on the old behaviour and pass now (423 + 54); valid values parse identically (tests) and give byte-identical output end to end;
--helpis unchanged; fmt/clippy clean on 1.99.1; 14-run sample sweep identical to master.