Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
automata: fix validation order in dense::DFA::from_bytes
  • Loading branch information
Mrmaxmeier committed Sep 12, 2025
commit 09b55df98d058e656689a0234a2790a6d153795f
8 changes: 6 additions & 2 deletions regex-automata/src/dfa/dense.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2340,10 +2340,14 @@ impl<'a> DFA<&'a [u32]> {
// table, match states and accelerators below. If any validation fails,
// then we return an error.
let (dfa, nread) = unsafe { DFA::from_bytes_unchecked(slice)? };
// Note: Validation order is important here:
// - MatchState::validate can be called with an untrusted DFA.
// - TransistionTable::validate uses dfa.ms through match_len
// - StartTable::validate needs a valid transition table
dfa.accels.validate()?;
dfa.ms.validate(&dfa)?;
dfa.tt.validate(&dfa)?;
dfa.st.validate(&dfa)?;
dfa.ms.validate(&dfa)?;
dfa.accels.validate()?;
// N.B. dfa.special doesn't have a way to do unchecked deserialization,
// so it has already been validated.
for state in dfa.states() {
Expand Down
Loading