mirror of https://github.com/OISF/suricata
detect/pcre: skip flow captures on flowless packets
DetectPcrePayloadMatch dispatched each capture group through a chain of captype tests whose flow-variable arm also required a non-NULL flow, and closed with an else that called BUG_ON(1) on the grounds that the captype was impossible. A capture typed VAR_TYPE_FLOW_VAR on a packet inspected without a flow, such as an ICMPv4 error message, matched no arm of that chain and reached the else. BUG_ON expands to assert() wherever assert.h is available and NDEBUG is unset and to exit(EXIT_FAILURE) otherwise, so one pcre rule whose flow capture matched such a packet killed the process. Test the captype before the substring is extracted and skip a flow capture when there is no flow, so nothing is allocated for a capture that has nowhere to go. The remaining capture groups of the same pcre still run: a rule that captures one group into a flow variable and the next into a packet variable still stores the packet variable. The SCFree(str_ptr) below BUG_ON(1) could never run, because BUG_ON terminates the process first. Use DEBUG_VALIDATE_BUG_ON instead, which compiles out unless debug validation is enabled, so a captype the parser cannot produce releases its capture rather than ending the process. Issue: 8862pull/16213/head
parent
b71178b667
commit
6afe490b46
Loading…
Reference in New Issue