Skip to content

automata: reject universal start states that disagree with the start table - #1428

Open
safa-rk wants to merge 1 commit into
rust-lang:masterfrom
safa-rk:dfa-universal-start-validate
Open

safa-rk wants to merge 1 commit into
rust-lang:masterfrom
safa-rk:dfa-universal-start-validate

Conversation

@safa-rk

@safa-rk safa-rk commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

dense and sparse from_bytes don't check the universal start state IDs against the start table. sparse StartTable::validate never looks at them, and dense only checks that they're in bounds. a DFA only has a universal start state when every look-behind context maps to the same start state, and find_fwd_imp/find_rev_imp use universal_start_state().is_some() to skip prefilter_restart after a prefilter candidate. so a deserialized dense DFA for (?-u:\b)foo with a forged universal start, after set_prefilter with a prefilter for foo, reports a match ending at 4 in xfoo foo instead of 8. the dense universal start can also be a match state, and the sparse one can point into the middle of a state, where next_state panics with a subtraction overflow. this requires each universal start to equal every start table entry for its anchor mode in both StartTable::validate impls, which also makes it a valid non-match state, and adds a regression test to each of the dense and sparse unit tests.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant