Parser: Fix inverted version pragma range comparison for large components - #16923
Open
riba2534 wants to merge 1 commit into
Open
Parser: Fix inverted version pragma range comparison for large components#16923riba2534 wants to merge 1 commit into
riba2534 wants to merge 1 commit into
Conversation
…ents Version pragma components are unsigned and the parser accepts values up to 2^32-1. Comparing them by casting to signed int overflowed for components in [2^31, 2^32) and inverted the range check, so an unsatisfiable constraint such as `>3000000000.0.0` was accepted and a satisfiable `<3000000000.0.0` was rejected. Compare the components as unsigned integers instead. Fixes argotorg#16803
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.
Description
Fixes #16803.
Version pragma components are unsigned and the parser already accepts values up to
2**32-1. Range comparison, however, cast each component to signedintand subtracted. For a component in[2**31, 2**32)that overflowed and flipped the sign of the result, so:pragma solidity >3000000000.0.0;(unsatisfiable) compiledpragma solidity <3000000000.0.0;(always satisfiable) was rejectedCompare the components as unsigned integers instead. Existing comparisons below
2**31are unchanged.Checklist
AI Disclosure
This change was implemented with assistance from Grok (xAI). I reviewed the root cause, the unsigned comparison, the new unit/syntax tests, and the changelog entry.
Tests
./scripts/soltest.sh -t SemVerMatcher --no-smt --no-semantic-tests./scripts/soltest.sh -t syntaxTests/pragma --no-smt --no-semantic-tests