From: Victor Julien Date: Sat, 7 Oct 2017 10:17:39 +0000 (+0200) Subject: detect: move detect cleanup into util func X-Git-Tag: suricata-4.1.0-beta1~369 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=70597066e0046abc6104190386e9ade3decb9796;p=thirdparty%2Fsuricata.git detect: move detect cleanup into util func --- diff --git a/src/detect.c b/src/detect.c index 2e374896ba..d408a74dfa 100644 --- a/src/detect.c +++ b/src/detect.c @@ -72,6 +72,9 @@ #include "util-validate.h" #include "util-detect.h" +static void SigMatchSignaturesCleanup(DetectEngineThreadCtx *det_ctx, + Packet *p, Flow *pflow, const bool use_flow_sgh); + int SigMatchSignaturesRunPostMatch(ThreadVars *tv, DetectEngineCtx *de_ctx, DetectEngineThreadCtx *det_ctx, Packet *p, const Signature *s) @@ -935,6 +938,14 @@ end: } PACKET_PROFILING_DETECT_END(p, PROF_DETECT_ALERT); + SigMatchSignaturesCleanup(det_ctx, p, pflow, use_flow_sgh); + SCReturn; +} + +/* TODO move use_flow_sgh into det_ctx */ +static void SigMatchSignaturesCleanup(DetectEngineThreadCtx *det_ctx, + Packet *p, Flow * const pflow, const bool use_flow_sgh) +{ PACKET_PROFILING_DETECT_START(p, PROF_DETECT_CLEANUP); /* cleanup pkt specific part of the patternmatcher */ PacketPatternCleanup(det_ctx); @@ -942,7 +953,7 @@ end: /* store the found sgh (or NULL) in the flow to save us from looking it * up again for the next packet. Also return any stream chunk we processed * to the pool. */ - if (p->flags & PKT_HAS_FLOW) { + if (pflow != NULL) { /* HACK: prevent the wrong sgh (or NULL) from being stored in the * flow's sgh pointers */ if (PKT_IS_ICMPV4(p) && ICMPV4_DEST_UNREACH_IS_VALID(p)) {