From 70597066e0046abc6104190386e9ade3decb9796 Mon Sep 17 00:00:00 2001 From: Victor Julien Date: Sat, 7 Oct 2017 12:17:39 +0200 Subject: [PATCH] detect: move detect cleanup into util func --- src/detect.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) 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)) {