Conversation
The Yul object parser's @use-src directive only allows decimal source indices per its grammar (UseSrc := [0-9]+ ':' FileName), but the index was parsed with toUnsignedInt(), which called std::stoul() without checking how many characters were consumed. std::stoul() stops at the first non-digit, so inputs such as 0x10 or 1e2 were silently truncated to 0 and 1 respectively and accepted as valid source indices, building a wrong source mapping instead of being reported as a syntax error (error 9804). Make toUnsignedInt() require the whole string to be consumed, so a number followed by trailing characters (including hex/binary/scientific literals) is rejected. Add regression tests for the @use-src parser and for toUnsignedInt() itself.
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
Checklist
The Yul object parser's @use-src directive only allows decimal source indices per
its grammar (UseSrc := [0-9]+ ':' FileName), but the index was parsed with
toUnsignedInt(), which called std::stoul() without checking how many characters
were consumed.
std::stoul() stops at the first non-digit, so inputs such as 0x10 or 1e2 were
silently truncated to 0 and 1 respectively and accepted as valid source indices,
building a wrong source mapping instead of being reported as a syntax error
(error 9804).
This makes toUnsignedInt() require the whole string to be consumed, so a number
followed by trailing characters (including hex/binary/scientific literals) is rejected.
The behavior is covered by new regression tests in the @use-src parser tests and in
the toUnsignedInt() unit tests.
AI Disclosure