Conversation
Author
|
The problem was found using the svace static analyzer |
consumeUnquotedIdentifier guards the identifierTrailingBits lookup with `r > 128`, but the bit mask is a [2]uint64 covering runes 0-127. For r == 128 (U+0080) the guard passes and the index expression evaluates to identifierTrailingBits[2], which panics with "index out of range [2] with length 2". Any expression where an unquoted identifier is followed by U+0080 hits this, for example "a\u0080". It is reachable from the public API, so Search and Compile panic on an untrusted expression instead of returning a syntax error. Change the guard to `r >= 128`. After the fix the rune falls through to tokenize, which reports "Unknown char: '\u0080'", matching the behaviour of every other non-ASCII rune (U+0081 and above already errored). Signed-off-by: maksim.nabokikh <max.nabokih@gmail.com>
nabokihms
force-pushed
the
fix-unquoted-identifier-oob
branch
from
September 14, 2026 09:22
2d71f54 to
b0d431c
Compare
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.
consumeUnquotedIdentifierguards theidentifierTrailingBitslookup withr > 128, but the mask is a[2]uint64covering runes 0-127. Atr == 128the guard passes and the lookup indexesidentifierTrailingBits[2]:Any expression with an unquoted identifier followed by U+0080 hits it,
a\u0080for example.SearchandCompileare public, so an untrusted expression panics instead of returning a syntax error.The guard is now
r >= 128. The rune falls through totokenize, which reportsUnknown char: '\u0080', the same as every other non-ASCII rune (U+0081 and above already errored). Two cases added tolexingErrorTests.