]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
alert: fixes leak in ThresholdHandlePacketRule 6701/head
authorPhilippe Antoine <contact@catenacyber.fr>
Tue, 5 Oct 2021 19:14:18 +0000 (21:14 +0200)
committerShivani Bhardwaj <shivanib134@gmail.com>
Fri, 10 Dec 2021 18:34:06 +0000 (00:04 +0530)
ThresholdHandlePacketRule may take ownership of an allocated
DetectThresholdEntry, and places it in a position of the
array th_entry. But it never got released

(cherry picked from commit 6fadb97d5ded5805745bca02bfb962de975ec122)

src/detect-engine-threshold.c

index 355e1dc35dcb37045ae9b59ec0f7406865ba5f23..1fabcef960d6d561636352b5263e1d27bbb634e7 100644 (file)
@@ -727,8 +727,14 @@ void ThresholdHashAllocate(DetectEngineCtx *de_ctx)
  */
 void ThresholdContextDestroy(DetectEngineCtx *de_ctx)
 {
-    if (de_ctx->ths_ctx.th_entry != NULL)
+    if (de_ctx->ths_ctx.th_entry != NULL) {
+        for (uint32_t i = 0; i < de_ctx->ths_ctx.th_size; i++) {
+            if (de_ctx->ths_ctx.th_entry[i] != NULL) {
+                SCFree(de_ctx->ths_ctx.th_entry[i]);
+            }
+        }
         SCFree(de_ctx->ths_ctx.th_entry);
+    }
     SCMutexDestroy(&de_ctx->ths_ctx.threshold_table_lock);
 }