]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
pfring: fix leak of configuration data and in single mode 10525/head
authorJason Ish <jason.ish@oisf.net>
Tue, 27 Feb 2024 22:55:59 +0000 (16:55 -0600)
committerVictor Julien <victor@inliniac.net>
Wed, 28 Feb 2024 13:24:03 +0000 (14:24 +0100)
Fix leak of configuration data on exit. Also, in single mode set
thread count to one instead of the CPU count.

Bug: #4734

src/runmode-pfring.c
src/source-pfring.c

index b0af83b4bfc25eef0369a1892aacec2c45d4edeb..7f1f74f40fdaba2074425ed52f5db0afde5a9c1e 100644 (file)
@@ -200,6 +200,7 @@ static void *ParsePfringConfig(const char *iface)
     cluster_type default_ctype = CLUSTER_FLOW;
     int getctype = 0;
     int bool_val;
+    const char *active_runmode = RunmodeGetActive();
 
     if (unlikely(pfconf == NULL)) {
         return NULL;
@@ -244,7 +245,9 @@ static void *ParsePfringConfig(const char *iface)
         if_default = NULL;
     }
 
-    if (ConfGetChildValueWithDefault(if_root, if_default, "threads", &threadsstr) != 1) {
+    if (active_runmode && !strcmp("single", active_runmode)) {
+        pfconf->threads = 1;
+    } else if (ConfGetChildValueWithDefault(if_root, if_default, "threads", &threadsstr) != 1) {
         pfconf->threads = 1;
     } else if (threadsstr != NULL) {
         if (strcmp(threadsstr, "auto") == 0) {
index 09efe8ac04947f37c8263b56f9652084df4de125..3ec02327f92d64c19322870c85fb8a8c7c57074d 100644 (file)
@@ -701,6 +701,7 @@ TmEcode ReceivePfringThreadDeinit(ThreadVars *tv, void *data)
     }
 
     pfring_close(ptv->pd);
+    SCFree(ptv);
     return TM_ECODE_OK;
 }