Reject negative choice values in SetType#1112
Open
raphaelroshan wants to merge 1 commit into
Open
Conversation
A <choice> value is a bit position and must be in [0, size * 8). The bounds check only guarded the upper limit, so a negative value passed validation and was later emitted as a shift amount in generated code, where 1 << -1 is silently masked to 1 << 31 -- producing wrong encode/decode masking for an invalid schema. Reject negative values too.
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.
A
<choice>value is a bit position and must be in[0, size * 8). The bounds check only guarded the upper limit, so a negative value (e.g.-1) passed schema validation and was later emitted as a shift amount in generated code, where1 << -1is silently masked to1 << 31— producing wrong encode/decode masking for an invalid schema.Reject negative values too (
value < 0 || value >= size * 8). Added a test symmetric to the existing upper-bound one.