File tree Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Original file line number Diff line number Diff line change @@ -2340,10 +2340,14 @@ impl<'a> DFA<&'a [u32]> {
2340
2340
// table, match states and accelerators below. If any validation fails,
2341
2341
// then we return an error.
2342
2342
let ( dfa, nread) = unsafe { DFA :: from_bytes_unchecked ( slice) ? } ;
2343
+ // Note: Validation order is important here:
2344
+ // - MatchState::validate can be called with an untrusted DFA.
2345
+ // - TransistionTable::validate uses dfa.ms through match_len
2346
+ // - StartTable::validate needs a valid transition table
2347
+ dfa. accels . validate ( ) ?;
2348
+ dfa. ms . validate ( & dfa) ?;
2343
2349
dfa. tt . validate ( & dfa) ?;
2344
2350
dfa. st . validate ( & dfa) ?;
2345
- dfa. ms . validate ( & dfa) ?;
2346
- dfa. accels . validate ( ) ?;
2347
2351
// N.B. dfa.special doesn't have a way to do unchecked deserialization,
2348
2352
// so it has already been validated.
2349
2353
for state in dfa. states ( ) {
You can’t perform that action at this time.
0 commit comments