Pairs
can be made with mismatched input str
and Vec<QueueableToken>
using pest::state
#993
Labels
Pairs
can be made with mismatched input str
and Vec<QueueableToken>
using pest::state
#993
In
pest::state
, after parsing theinput
using the provided closure, the result is used to construct aPairs
with the originalinput
string, but the returnedVec<QueueableToken>
. This can be misused to create aPosition
which does not correspond to a valid unicode codepoint boundary in the input string it holds a reference to.Note that this does not currently allow for undefined behavior, but only because the safe boundary-checked
str
indexing is used. The code has a number of unsafe functions and unsafe blocks which claim that this invariant is never violated, which could lead to an exploit if it is relied on.One way to fix this would be to drop the invariant that the token positions correspond to valid codepoint boundaries in the input string.
To Reproduce
This panics because the state we returned had a different input string than the one we called
pest::state
with.Expected behavior
It should not be possible to create a
Pairs
with mismatched input string andQueueableToken
s.Additional context
Discovered during Fuchsia unsafe review at https://fxrev.dev/1003433.
The text was updated successfully, but these errors were encountered: