]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
detect-ssl-version: simplify code and fix memlea
authorEric Leblond <eric@regit.org>
Sun, 6 Mar 2016 20:40:18 +0000 (21:40 +0100)
committerEric Leblond <eric@regit.org>
Mon, 7 Mar 2016 22:29:58 +0000 (23:29 +0100)
src/detect-ssl-version.c

index 599d26b87764b62fae7406cd8682457ad5c9b665..266c15d68d85704dc6d7b2b8844f74c47fcc81dc 100644 (file)
@@ -200,7 +200,7 @@ DetectSslVersionData *DetectSslVersionParse(char *str)
     }
 
     if (ret > 1) {
-        const char *str_ptr[5];
+        const char *str_ptr;
         char *orig;
         uint8_t found = 0, neg = 0;
         char *tmp_str;
@@ -212,7 +212,7 @@ DetectSslVersionData *DetectSslVersionParse(char *str)
 
         int i;
         for (i = 1; i < ret; i++) {
-            res = pcre_get_substring((char *) str, ov, MAX_SUBSTRINGS, i, &str_ptr[i]);
+            res = pcre_get_substring((char *) str, ov, MAX_SUBSTRINGS, i, &str_ptr);
             if (res < 0) {
                 SCLogError(SC_ERR_PCRE_GET_SUBSTRING, "pcre_get_substring failed");
                 if (found == 0)
@@ -220,7 +220,7 @@ DetectSslVersionData *DetectSslVersionParse(char *str)
                 break;
             }
 
-            orig = SCStrdup((char*) str_ptr[i]);
+            orig = SCStrdup((char*) str_ptr);
             if (unlikely(orig == NULL)) {
                 goto error;
             }
@@ -272,6 +272,7 @@ DetectSslVersionData *DetectSslVersionParse(char *str)
             found = 1;
             neg = 0;
             SCFree(orig);
+            pcre_free_substring(str_ptr);
         }
     }