]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
Fix small memory leak in classtype parsing
authorVictor Julien <victor@inliniac.net>
Mon, 9 Dec 2013 17:48:42 +0000 (18:48 +0100)
committerVictor Julien <victor@inliniac.net>
Mon, 9 Dec 2013 18:05:50 +0000 (19:05 +0100)
src/detect-classtype.c

index 1c76120ef1986deec48f1fd052cf7dc08e758c1f..fd0aebeb88f1bec9b3f616f04628e62a3032520a 100644 (file)
@@ -93,17 +93,16 @@ static int DetectClasstypeParseRawString(char *rawstr, char *out, size_t outsize
 #define MAX_SUBSTRINGS 30
     int ret = 0;
     int ov[MAX_SUBSTRINGS];
+    size_t len = strlen(rawstr);
 
     /* get rid of the double quotes if present */
     if (rawstr[0] == '\"' && rawstr[strlen(rawstr) - 1] == '\"') {
-        if ( (rawstr = SCStrdup(rawstr + 1)) == NULL) {
-            SCLogError(SC_ERR_MEM_ALLOC, "Error allocating memory");
-            goto end;
-        }
+        rawstr++;
         rawstr[strlen(rawstr) - 1] = '\0';
+        len -= 2;
     }
 
-    ret = pcre_exec(regex, regex_study, rawstr, strlen(rawstr), 0, 0, ov, 30);
+    ret = pcre_exec(regex, regex_study, rawstr, len, 0, 0, ov, 30);
     if (ret < 0) {
         SCLogError(SC_ERR_PCRE_MATCH, "Invalid Classtype in Signature");
         goto end;