diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2015-09-15 06:58:43 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2015-09-15 06:58:43 -0700 |
commit | 221c736a969f7305ffabc9a37b968879aed0affc (patch) | |
tree | 0a42329f3b82fb8879bfdd5a946ab52b09fba34a /signal.h | |
parent | 815f1dcda70f161b09813fc4fddc24c522ea71bf (diff) | |
download | txr-221c736a969f7305ffabc9a37b968879aed0affc.tar.gz txr-221c736a969f7305ffabc9a37b968879aed0affc.tar.bz2 txr-221c736a969f7305ffabc9a37b968879aed0affc.zip |
Regex state-marking counter wraparound bug.
When a NFA regex goes through more than 4.29 billion state
transitions, the state coloring "visited" marker wraps around.
There could still exist states with old values at or near
zero, which destroys the correctness of the closure
calculations.
* regex.c (nfa_handle_wraparound): New static function.
The wraparound situation is handled by detecting when
the next marker value is UINT_MAX. When this happens,
we visit all states, marking them to UINT_MAX.
Then we visit them again, marking them to zero, and
set the next marker value to 1.
(nfa_free): Added comment about why we don't have a
wraparound check, in case it isn't obvious.
(nfa_run): Check for wraparound before eveyr nfa_closure call.
(regex_machine_reset): Check for wraparound before nfa_closure
call. Fix: store the counter back in the start state's visited
field.
(regex_machine_init): Initialize the n.visited field of the
regex machine structure to zero. Not strictly necessary, since
it's initialized moments later in regex_machine_reset, but
good form.
(regex_machine_feed): Check for wraparound before nfa_closure
call.
Diffstat (limited to 'signal.h')
0 files changed, 0 insertions, 0 deletions