]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
tls: suppress always true condition. 34/head
authorEric Leblond <eric@regit.org>
Thu, 23 Aug 2012 15:06:39 +0000 (17:06 +0200)
committerEric Leblond <eric@regit.org>
Fri, 24 Aug 2012 10:59:12 +0000 (12:59 +0200)
src/detect-tls.c

index deeab3f1ecfc69f2efd94b719cfc013ccb782eb5..a54c5ba8cefc1acc9520bef512dd063e1d5e2a48 100644 (file)
@@ -448,6 +448,10 @@ static DetectTlsData *DetectTlsIssuerDNParse(char *str)
 #define MAX_SUBSTRINGS 30
     int ret = 0, res = 0;
     int ov[MAX_SUBSTRINGS];
+    const char *str_ptr;
+    char *orig;
+    char *tmp_str;
+    uint32_t flag = 0;
 
     ret = pcre_exec(issuerdn_parse_regex, issuerdn_parse_regex_study, str, strlen(str), 0, 0,
                     ov, MAX_SUBSTRINGS);
@@ -457,52 +461,45 @@ static DetectTlsData *DetectTlsIssuerDNParse(char *str)
         goto error;
     }
 
-    if (ret == 3) {
-        const char *str_ptr;
-        char *orig;
-        char *tmp_str;
-        uint32_t flag = 0;
+    res = pcre_get_substring((char *)str, ov, MAX_SUBSTRINGS, 1, &str_ptr);
+    if (res < 0) {
+        SCLogError(SC_ERR_PCRE_GET_SUBSTRING, "pcre_get_substring failed");
+        goto error;
+    }
+    if (str_ptr[0] == '!')
+        flag = DETECT_CONTENT_NEGATED;
 
-        res = pcre_get_substring((char *)str, ov, MAX_SUBSTRINGS, 1, &str_ptr);
-        if (res < 0) {
-            SCLogError(SC_ERR_PCRE_GET_SUBSTRING, "pcre_get_substring failed");
-            goto error;
-        }
-        if (str_ptr[0] == '!')
-            flag = DETECT_CONTENT_NEGATED;
+    res = pcre_get_substring((char *)str, ov, MAX_SUBSTRINGS, 2, &str_ptr);
+    if (res < 0) {
+        SCLogError(SC_ERR_PCRE_GET_SUBSTRING, "pcre_get_substring failed");
+        goto error;
+    }
 
-        res = pcre_get_substring((char *)str, ov, MAX_SUBSTRINGS, 2, &str_ptr);
-        if (res < 0) {
-            SCLogError(SC_ERR_PCRE_GET_SUBSTRING, "pcre_get_substring failed");
-            goto error;
-        }
+    /* We have a correct id option */
+    tls = SCMalloc(sizeof(DetectTlsData));
+    if (tls == NULL)
+        goto error;
+    tls->issuerdn = NULL;
+    tls->flags = flag;
 
-        /* We have a correct id option */
-        tls = SCMalloc(sizeof(DetectTlsData));
-        if (tls == NULL)
-            goto error;
-        tls->issuerdn = NULL;
-        tls->flags = flag;
-
-        orig = SCStrdup((char*)str_ptr);
-        tmp_str=orig;
-        if (tmp_str == NULL) {
-            goto error;
-        }
+    orig = SCStrdup((char*)str_ptr);
+    tmp_str=orig;
+    if (tmp_str == NULL) {
+        goto error;
+    }
 
-        /* Let's see if we need to escape "'s */
-        if (tmp_str[0] == '"')
-        {
-            tmp_str[strlen(tmp_str) - 1] = '\0';
-            tmp_str += 1;
-        }
+    /* Let's see if we need to escape "'s */
+    if (tmp_str[0] == '"')
+    {
+        tmp_str[strlen(tmp_str) - 1] = '\0';
+        tmp_str += 1;
+    }
 
-        tls->issuerdn = SCStrdup(tmp_str);
+    tls->issuerdn = SCStrdup(tmp_str);
 
-        SCFree(orig);
+    SCFree(orig);
 
-        SCLogDebug("will look for TLS issuerdn %s", tls->issuerdn);
-    }
+    SCLogDebug("Will look for TLS issuerdn %s", tls->issuerdn);
 
     return tls;