Repository navigation
Conversation
…ecode decoder read_bytes checked `pos + n > len`, which overflows for a huge section length; check `n > remaining()` instead. read_varint accepted a 10th byte with payload > 1 and silently truncated the value; reject it. Transplanted from NVlabs/cutile-rs#322. Signed-off-by: dawnop <dawnlulucifer@gmail.com>
This branch has not been deployed
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.
Transplanted from NVlabs/cutile-rs#322, which was closed when the repository moved here. Closes #1443.
Fixes two input-validation bugs in
cutile-ir's bytecodeReader:read_bytescheckedself.pos + n > len, which overflows for a hugesection length. Debug builds panic on the overflow. In release builds the
sum wraps, the check passes, and the slice then panics. It now checks
n > self.remaining().read_varintaccepted a 10th byte with payload > 1. The extra high bitswere shifted out, so the value was silently truncated. For example, a
section length could wrap to 1 and be accepted. It now rejects a 10th byte
other than
0x00/0x01.Tests:
decode_rejection.rs:reject_section_length_overflowandreject_section_length_varint_overflowboth fail onmainand pass withthis change.
decoder.rs:varint_u64_boundariesround-trips 0, 127, 128, 2^63 andu64::MAX.cargo test -p cutile-ir,cargo fmt --checkandcargo clippy --all-targets -- -D warningspass undercutile-rs/with the pinned 1.98.0 toolchain. The change is identical to #322, wherebash scripts/run_all.shpassed locally.