]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
detect-iprep: fix memory leaks
authorGiuseppe Longo <giuseppe@glongo.it>
Sat, 9 Mar 2019 21:36:03 +0000 (22:36 +0100)
committerVictor Julien <victor@inliniac.net>
Thu, 14 Mar 2019 15:25:53 +0000 (16:25 +0100)
Loading rules with iprep keyword cause
memory leaks due to missing frees.

Direct leak of 8 byte(s) in 4 object(s) allocated from:
    #0 0x7f81c862bd28 in malloc (/usr/lib/x86_64-linux-gnu/libasan.so.3+0xc1d28)
    #1 0x7f81c6afea69 in pcre_get_substring (/lib/x86_64-linux-gnu/libpcre.so.3+0x27a69)
    #2 0x43206f7420676e68  (<unknown module>)

SUMMARY: AddressSanitizer: 8 byte(s) leaked in 4 allocation(s).

src/detect-iprep.c

index e3cfe1b032887a21eac304b3d104678a13dab631..765ceabdae39896fd4040215d18a254c4ee38ca1 100644 (file)
@@ -341,6 +341,10 @@ int DetectIPRepSetup (DetectEngineCtx *de_ctx, Signature *s, const char *rawstr)
     name = NULL;
     pcre_free_substring(cmd_str);
     cmd_str = NULL;
+    pcre_free_substring(op_str);
+    op_str = NULL;
+    pcre_free_substring(value);
+    value = NULL;
 
     /* Okay so far so good, lets get this into a SigMatch
      * and put it in the Signature. */
@@ -360,6 +364,10 @@ error:
         pcre_free_substring(name);
     if (cmd_str != NULL)
         pcre_free_substring(cmd_str);
+    if (op_str != NULL)
+        pcre_free_substring(op_str);
+    if (value != NULL)
+        pcre_free_substring(value);
     if (cd != NULL)
         SCFree(cd);
     if (sm != NULL)