fix reversed empty range in try_from_bytes - #11
Open
Zk-nd3r wants to merge 1 commit into
Open
Conversation
bytes[76 - 32..2] is bytes[44..2], a reversed range that panics on the first decode. The length guard above admits any input of 46 bytes or more, and the 2-byte signature-count field that follows the 44-byte vote header lives at bytes[44..46]. Fix the range and drop the clippy::reversed_empty_ranges allow that was hiding it.
Zk-nd3r
force-pushed
the
fix-reversed-empty-range-deserialize
branch
from
July 29, 2026 18:45
9d4ad5b to
59552e3
Compare
Contributor
Author
|
Retargeted to |
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.
bytes[76 - 32..2] is bytes[44..2], a reversed range. The 46-byte length guard above (if bytes.len() < 76 - 32 + 2) and the 2-byte length field that follows the 44-byte vote header point at bytes[76 - 32..76 - 32 + 2].
Same copy-paste at 4 sites, all suppressing clippy::reversed_empty_ranges:
No callers of these functions in tree right now so this is latent. Anything that wires them up later crashes on the first decode. Fixed the range and dropped the allow at all 4 sites.