Skip to content

Parser: Fix inverted version pragma range comparison for large components - #16923

Open
riba2534 wants to merge 1 commit into
argotorg:developfrom
riba2534:fix/issue-16803
Open

Parser: Fix inverted version pragma range comparison for large components#16923
riba2534 wants to merge 1 commit into
argotorg:developfrom
riba2534:fix/issue-16803

Conversation

@riba2534

Copy link
Copy Markdown

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 signed int and 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) compiled
  • pragma solidity <3000000000.0.0; (always satisfiable) was rejected

Compare the components as unsigned integers instead. Existing comparisons below 2**31 are unchanged.

Checklist

AI Disclosure

  • No AI tools were used

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

…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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Signed-cast overflow inverts version pragma range check

1 participant