]> git.ipfire.org Git - people/ms/suricata.git/commitdiff
Fix a number of potential issues found by CLANG and cppcheck.
authorVictor Julien <victor@inliniac.net>
Wed, 2 Nov 2011 09:57:56 +0000 (10:57 +0100)
committerVictor Julien <victor@inliniac.net>
Wed, 2 Nov 2011 09:59:29 +0000 (10:59 +0100)
src/alert-prelude.c
src/app-layer-parser.c
src/counters.c
src/decode-gre.c
src/detect-engine-address-ipv4.c
src/detect-engine-sigorder.c
src/detect-fast-pattern.c
src/detect-ipproto.c
src/util-pool.c

index c25cd66e628ddafc4f90591ae64513b709c48b24..70733bd4025dc477e8ccfd9d6b250cdb85866daa 100644 (file)
@@ -659,7 +659,7 @@ TmEcode AlertPrelude (ThreadVars *tv, Packet *p, void *data, PacketQueue *pq, Pa
     idmef_time_t *time;
     idmef_alert_t *alert;
     prelude_string_t *str;
-    idmef_message_t *idmef;
+    idmef_message_t *idmef = NULL;
     idmef_classification_t *class;
     PacketAlert *pa;
 
@@ -748,7 +748,8 @@ TmEcode AlertPrelude (ThreadVars *tv, Packet *p, void *data, PacketQueue *pq, Pa
     SCReturnInt(TM_ECODE_OK);
 
 err:
-    idmef_message_destroy(idmef);
+    if (idmef != NULL)
+        idmef_message_destroy(idmef);
     SCReturnInt(TM_ECODE_FAILED);
 }
 
index 3982b0dd9a7959055efbd843f2c931b12d11ac87..89cbf656cf048afe3564108dfe5d2c901ba9d401 100644 (file)
@@ -1774,6 +1774,7 @@ void AppLayerRegisterProbingParser(AlpProtoDetectCtx *ctx,
 {
     AppLayerProbingParser **probing_parsers = &ctx->probing_parsers;
     AppLayerProbingParserElement *pe = NULL;
+    AppLayerProbingParserElement *new_pe = NULL;
     AppLayerProbingParser *pp = NULL;
 
     /* Add info about this probing parser to our database.  Also detects any
@@ -1786,8 +1787,7 @@ void AppLayerRegisterProbingParser(AlpProtoDetectCtx *ctx,
     /* \todo introduce parsing port range here */
 
     /* Get a new parser element */
-    AppLayerProbingParserElement *new_pe =
-        AppLayerCreateAppLayerProbingParserElement(al_proto_name, ip_proto,
+    new_pe = AppLayerCreateAppLayerProbingParserElement(al_proto_name, ip_proto,
                                                    al_proto, min_depth,
                                                    max_depth, port,
                                                    priority, top,
index e0763db56d09c0d418aab45b4d34e335cbab3ba8..f42711490e0300404a7976d47f837f5fb4a6026c 100644 (file)
@@ -400,28 +400,26 @@ static void SCPerfReleaseOPCtx()
     SCPerfClubTMInst *temp = NULL;
     pctmi = sc_perf_op_ctx->pctmi;
 
-    if (sc_perf_op_ctx != NULL) {
-        if (sc_perf_op_ctx->fp != NULL)
-            fclose(sc_perf_op_ctx->fp);
+    if (sc_perf_op_ctx->fp != NULL)
+        fclose(sc_perf_op_ctx->fp);
 
-        if (sc_perf_op_ctx->file != NULL)
-            SCFree(sc_perf_op_ctx->file);
+    if (sc_perf_op_ctx->file != NULL)
+        SCFree(sc_perf_op_ctx->file);
 
-        while (pctmi != NULL) {
-            if (pctmi->tm_name != NULL)
-                SCFree(pctmi->tm_name);
+    while (pctmi != NULL) {
+        if (pctmi->tm_name != NULL)
+            SCFree(pctmi->tm_name);
 
-            if (pctmi->head != NULL)
-                SCFree(pctmi->head);
+        if (pctmi->head != NULL)
+            SCFree(pctmi->head);
 
-            temp = pctmi->next;
-            SCFree(pctmi);
-            pctmi = temp;
-        }
-
-        SCFree(sc_perf_op_ctx);
+        temp = pctmi->next;
+        SCFree(pctmi);
+        pctmi = temp;
     }
 
+    SCFree(sc_perf_op_ctx);
+
     return;
 }
 
index de5043494c4635edc9adfc0a11341063e4fa9942..dc5271aa784fb11bb9b969d51ec1ea5b74f15719 100644 (file)
@@ -103,10 +103,6 @@ void DecodeGRE(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p, uint8_t *pkt, u
 
             if (GRE_FLAG_ISSET_ROUTE(p->greh))
             {
-                gsre = (GRESreHdr *)(pkt + header_len);
-                if (gsre == NULL)
-                    return;
-
                 while (1)
                 {
                     if ((header_len + GRE_SRE_HDR_LEN) > len) {
@@ -114,9 +110,11 @@ void DecodeGRE(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p, uint8_t *pkt, u
                         return;
                     }
 
+                    gsre = (GRESreHdr *)(pkt + header_len);
+
                     header_len += GRE_SRE_HDR_LEN;
 
-                    if (gsre != NULL && (ntohs(gsre->af) == 0) && (gsre->sre_length == 0))
+                    if ((ntohs(gsre->af) == 0) && (gsre->sre_length == 0))
                         break;
 
                     header_len += gsre->sre_length;
@@ -124,10 +122,6 @@ void DecodeGRE(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p, uint8_t *pkt, u
                         ENGINE_SET_EVENT(p, GRE_VERSION0_MALFORMED_SRE_HDR);
                         return;
                     }
-
-                    gsre = (GRESreHdr *)(pkt + header_len);
-                    if (gsre == NULL)
-                        return;
                 }
             }
             break;
index e6577786dbbd9426fbba713a8d496e1891783b3e..d48ec1b4feae0798faa8df2bf1bfa6a76f6426a4 100644 (file)
@@ -606,13 +606,18 @@ int DetectAddressJoinIPv4(DetectEngineCtx *de_ctx, DetectAddress *target,
 
 static int DetectAddressIPv4TestAddressCmp01(void)
 {
-    DetectAddress *a = DetectAddressInit();
-    DetectAddress *b = DetectAddressInit();
     struct in_addr in;
     int result = 1;
 
-    if (a == NULL || b == NULL)
-        goto error;
+    DetectAddress *a = DetectAddressInit();
+    if (a == NULL)
+        return 0;
+
+    DetectAddress *b = DetectAddressInit();
+    if (b == NULL) {
+        DetectAddressFree(a);
+        return 0;
+    }
 
     if (inet_pton(AF_INET, "1.2.3.4", &in) < 0)
         goto error;
@@ -1036,17 +1041,13 @@ static int DetectAddressIPv4TestAddressCmp01(void)
     b->ip2.addr_data32[0] = in.s_addr;
     result &= (DetectAddressCmpIPv4(a, b) != ADDRESS_GT);
 
-    if (a != NULL)
-        DetectAddressFree(a);
-    if (b != NULL)
-        DetectAddressFree(b);
+    DetectAddressFree(a);
+    DetectAddressFree(b);
     return result;
 
  error:
-    if (a != NULL)
-        DetectAddressFree(a);
-    if (b != NULL)
-        DetectAddressFree(b);
+    DetectAddressFree(a);
+    DetectAddressFree(b);
     return 0;
 }
 
@@ -1255,12 +1256,11 @@ static int DetectAddressIPv4IsCompleteIPSpace04(void)
 static int DetectAddressIPv4CutNot05(void)
 {
     DetectAddress *a = NULL;
-    DetectAddress *b = NULL;
     struct in_addr in;
     int result = 1;
 
     if ( (a = DetectAddressInit()) == NULL)
-        goto error;
+        return 0;
 
     if (inet_pton(AF_INET, "0.0.0.0", &in) < 0)
         goto error;
@@ -1270,29 +1270,22 @@ static int DetectAddressIPv4CutNot05(void)
     a->ip2.addr_data32[0] = in.s_addr;
     result &= (DetectAddressCutNotIPv4(a, &b) == -1);
 
-    if (a != NULL)
-        DetectAddressFree(a);
-    if (b != NULL)
-        DetectAddressFree(b);
+    DetectAddressFree(a);
     return result;
 
  error:
-    if (a != NULL)
-        DetectAddressFree(a);
-    if (b != NULL)
-        DetectAddressFree(b);
+    DetectAddressFree(a);
     return 0;
 }
 
 static int DetectAddressIPv4CutNot06(void)
 {
     DetectAddress *a = NULL;
-    DetectAddress *b = NULL;
     struct in_addr in;
     int result = 1;
 
     if ( (a = DetectAddressInit()) == NULL)
-        goto error;
+        return 0;
 
     if (inet_pton(AF_INET, "0.0.0.0", &in) < 0)
         goto error;
@@ -1308,31 +1301,23 @@ static int DetectAddressIPv4CutNot06(void)
     if (inet_pton(AF_INET, "255.255.255.255", &in) < 0)
         goto error;
     result &= (a->ip2.addr_data32[0] = in.s_addr);
-    result &= (b == NULL);
 
-    if (a != NULL)
-        DetectAddressFree(a);
-    if (b != NULL)
-        DetectAddressFree(b);
+    DetectAddressFree(a);
     return result;
 
  error:
-    if (a != NULL)
-        DetectAddressFree(a);
-    if (b != NULL)
-        DetectAddressFree(b);
+    DetectAddressFree(a);
     return 0;
 }
 
 static int DetectAddressIPv4CutNot07(void)
 {
     DetectAddress *a = NULL;
-    DetectAddress *b = NULL;
     struct in_addr in;
     int result = 1;
 
     if ( (a = DetectAddressInit()) == NULL)
-        goto error;
+        return 0;
 
     if (inet_pton(AF_INET, "1.2.3.4", &in) < 0)
         goto error;
@@ -1348,19 +1333,12 @@ static int DetectAddressIPv4CutNot07(void)
     if (inet_pton(AF_INET, "1.2.3.3", &in) < 0)
         goto error;
     result &= (a->ip2.addr_data32[0] = in.s_addr);
-    result &= (b == NULL);
 
-    if (a != NULL)
-        DetectAddressFree(a);
-    if (b != NULL)
-        DetectAddressFree(b);
+    DetectAddressFree(a);
     return result;
 
  error:
-    if (a != NULL)
-        DetectAddressFree(a);
-    if (b != NULL)
-        DetectAddressFree(b);
+    DetectAddressFree(a);
     return 0;
 }
 
@@ -1372,7 +1350,7 @@ static int DetectAddressIPv4CutNot08(void)
     int result = 1;
 
     if ( (a = DetectAddressInit()) == NULL)
-        goto error;
+        return 0;
 
     if (inet_pton(AF_INET, "1.2.3.4", &in) < 0)
         goto error;
@@ -1402,15 +1380,13 @@ static int DetectAddressIPv4CutNot08(void)
         goto error;
     result &= (b->ip2.addr_data32[0] = in.s_addr);
 
-    if (a != NULL)
-        DetectAddressFree(a);
+    DetectAddressFree(a);
     if (b != NULL)
         DetectAddressFree(b);
     return result;
 
  error:
-    if (a != NULL)
-        DetectAddressFree(a);
+    DetectAddressFree(a);
     if (b != NULL)
         DetectAddressFree(b);
     return 0;
@@ -1424,7 +1400,7 @@ static int DetectAddressIPv4CutNot09(void)
     int result = 1;
 
     if ( (a = DetectAddressInit()) == NULL)
-        goto error;
+        return 0;
 
     if (inet_pton(AF_INET, "1.2.3.4", &in) < 0)
         goto error;
@@ -1454,15 +1430,13 @@ static int DetectAddressIPv4CutNot09(void)
         goto error;
     result &= (b->ip2.addr_data32[0] = in.s_addr);
 
-    if (a != NULL)
-        DetectAddressFree(a);
+    DetectAddressFree(a);
     if (b != NULL)
         DetectAddressFree(b);
     return result;
 
  error:
-    if (a != NULL)
-        DetectAddressFree(a);
+    DetectAddressFree(a);
     if (b != NULL)
         DetectAddressFree(b);
     return 0;
@@ -1470,13 +1444,18 @@ static int DetectAddressIPv4CutNot09(void)
 
 static int DetectAddressIPv4Join10(void)
 {
-    DetectAddress *source = DetectAddressInit();
-    DetectAddress *target = DetectAddressInit();
     struct in_addr in;
     int result = 1;
 
-    if (source == NULL || target == NULL)
-        goto error;
+    DetectAddress *source = DetectAddressInit();
+    if (source == NULL)
+        return 0;
+
+    DetectAddress *target = DetectAddressInit();
+    if (target == NULL) {
+        DetectAddressFree(source);
+        return 0;
+    }
 
     if (inet_pton(AF_INET, "128.51.61.124", &in) < 0)
         goto error;
@@ -1588,17 +1567,13 @@ static int DetectAddressIPv4Join10(void)
         goto error;
     result &= (target->ip2.addr_data32[0] == in.s_addr);
 
-    if (source != NULL)
-        DetectAddressFree(source);
-    if (target != NULL)
-        DetectAddressFree(target);
+    DetectAddressFree(source);
+    DetectAddressFree(target);
     return result;
 
  error:
-    if (source != NULL)
-        DetectAddressFree(source);
-    if (target != NULL)
-        DetectAddressFree(target);
+    DetectAddressFree(source);
+    DetectAddressFree(target);
     return 0;
 }
 
index 4aa145f7a4990f833ab8e7de8e39a1f2c7f2a5ad..8a01d9f0bc90e9ff9f695945702c96184e928b37 100644 (file)
@@ -296,6 +296,9 @@ static void SCSigOrderByAction(DetectEngineCtx *de_ctx,
     SCSigSignatureWrapper *max = NULL;
     SCSigSignatureWrapper *prev = NULL;
 
+    if (sw == NULL)
+        return;
+
     if (de_ctx->sc_sig_sig_wrapper == NULL) {
         de_ctx->sc_sig_sig_wrapper = sw;
         sw->min = NULL;
@@ -364,8 +367,6 @@ static void SCSigOrderByAction(DetectEngineCtx *de_ctx,
     }
 
     /* set the min signature for this keyword, for the next ordering function */
-    if (sw == NULL)
-        return;
     min = sw;
     while (min != NULL && min != sw->min) {
         if (min->sig->action != sw->sig->action)
@@ -376,8 +377,6 @@ static void SCSigOrderByAction(DetectEngineCtx *de_ctx,
     sw->min = min;
 
     /* set the max signature for this keyword + 1, for the next ordering func */
-    if (sw == NULL)
-        return;
     max = sw;
     while (max != NULL && max != sw->max) {
         if (max->sig->action != sw->sig->action)
@@ -404,6 +403,9 @@ static void SCSigOrderByFlowbits(DetectEngineCtx *de_ctx,
     SCSigSignatureWrapper *max = NULL;
     SCSigSignatureWrapper *prev = NULL;
 
+    if (sw == NULL)
+        return;
+
     if (de_ctx->sc_sig_sig_wrapper == NULL) {
         de_ctx->sc_sig_sig_wrapper = sw;
         sw->min = NULL;
@@ -473,8 +475,6 @@ static void SCSigOrderByFlowbits(DetectEngineCtx *de_ctx,
     }
 
     /* set the min signature for this keyword, for the next ordering function */
-    if (sw == NULL)
-        return;
     min = sw;
     while (min != NULL && min != sw->min) {
         if ( *((int *)(sw->user[SC_RADIX_USER_DATA_FLOWBITS])) !=
@@ -486,8 +486,6 @@ static void SCSigOrderByFlowbits(DetectEngineCtx *de_ctx,
     sw->min = min;
 
     /* set the max signature for this keyword + 1, for the next ordering func */
-    if (sw == NULL)
-        return;
     max = sw;
     while (max!= NULL && max != sw->max) {
         if ( *((int *)(sw->user[SC_RADIX_USER_DATA_FLOWBITS])) !=
@@ -516,6 +514,9 @@ static void SCSigOrderByFlowvar(DetectEngineCtx *de_ctx,
     SCSigSignatureWrapper *max = NULL;
     SCSigSignatureWrapper *prev = NULL;
 
+    if (sw == NULL)
+        return;
+
     if (de_ctx->sc_sig_sig_wrapper == NULL) {
         de_ctx->sc_sig_sig_wrapper = sw;
         sw->min = NULL;
@@ -585,8 +586,6 @@ static void SCSigOrderByFlowvar(DetectEngineCtx *de_ctx,
     }
 
     /* set the min signature for this keyword, for the next ordering function */
-    if (sw == NULL)
-        return;
     min = sw;
     while (min != NULL && min != sw->min) {
         if ( *((int *)(sw->user[SC_RADIX_USER_DATA_FLOWVAR])) !=
@@ -598,8 +597,6 @@ static void SCSigOrderByFlowvar(DetectEngineCtx *de_ctx,
     sw->min = min;
 
     /* set the max signature for this keyword + 1, for the next ordering func */
-    if (sw == NULL)
-        return;
     max = sw;
     while (max != NULL && max != sw->max) {
         if ( *((int *)(sw->user[SC_RADIX_USER_DATA_FLOWVAR])) !=
@@ -627,6 +624,9 @@ static void SCSigOrderByPktvar(DetectEngineCtx *de_ctx,
     SCSigSignatureWrapper *max = NULL;
     SCSigSignatureWrapper *prev = NULL;
 
+    if (sw == NULL)
+        return;
+
     if (de_ctx->sc_sig_sig_wrapper == NULL) {
         de_ctx->sc_sig_sig_wrapper = sw;
         sw->min = NULL;
@@ -695,9 +695,6 @@ static void SCSigOrderByPktvar(DetectEngineCtx *de_ctx,
     }
 
     /* set the min signature for this keyword, for the next ordering function */
-    if (sw == NULL)
-        return;
-
     min = sw;
     while (min != NULL && min != sw->min) {
         if ( *((int *)(sw->user[SC_RADIX_USER_DATA_PKTVAR])) !=
@@ -709,8 +706,6 @@ static void SCSigOrderByPktvar(DetectEngineCtx *de_ctx,
     sw->min = min;
 
     /* set the max signature for this keyword + 1, for the next ordering func */
-    if (sw == NULL)
-        return;
     max = sw;
     while (max != NULL && max != sw->max) {
         if ( *((int *)(sw->user[SC_RADIX_USER_DATA_PKTVAR])) !=
@@ -738,6 +733,9 @@ static void SCSigOrderByPriority(DetectEngineCtx *de_ctx,
     SCSigSignatureWrapper *max = NULL;
     SCSigSignatureWrapper *prev = NULL;
 
+    if (sw == NULL)
+        return;
+
     if (de_ctx->sc_sig_sig_wrapper == NULL) {
         de_ctx->sc_sig_sig_wrapper = sw;
         sw->min = NULL;
@@ -806,9 +804,6 @@ static void SCSigOrderByPriority(DetectEngineCtx *de_ctx,
     }
 
     /* set the min signature for this keyword, for the next ordering function */
-    if (sw == NULL)
-        return;
-
     min = sw;
     while (min != NULL && min != sw->min) {
         if (min->sig->prio != sw->sig->prio)
@@ -819,9 +814,6 @@ static void SCSigOrderByPriority(DetectEngineCtx *de_ctx,
     sw->min = min;
 
     /* set the max signature for this keyword + 1, for the next ordering func */
-    if (sw == NULL)
-        return;
-
     max = sw;
     while (max != NULL && max != sw->max) {
         if (max->sig->prio != sw->sig->prio)
index 91e9c77acca632690b8ec67ad0e3c873134042b7..e963c83952eb8d64814861f27f760f54dc6569ad 100644 (file)
@@ -1151,7 +1151,7 @@ int DetectFastPatternTest17(void)
     result = 0;
     sm = de_ctx->sig_list->sm_lists[DETECT_SM_LIST_PMATCH];
     DetectContentData *cd = sm->ctx;
-    if (sm != NULL && sm->type == DETECT_CONTENT) {
+    if (sm->type == DETECT_CONTENT) {
         if (cd->flags & DETECT_CONTENT_FAST_PATTERN &&
             cd->flags & DETECT_CONTENT_FAST_PATTERN_ONLY &&
             !(cd->flags & cd->flags & DETECT_CONTENT_FAST_PATTERN_CHOP) &&
@@ -1187,7 +1187,7 @@ int DetectFastPatternTest18(void)
     result = 0;
     sm = de_ctx->sig_list->sm_lists[DETECT_SM_LIST_PMATCH];
     DetectContentData *cd = sm->ctx;
-    if (sm != NULL && sm->type == DETECT_CONTENT) {
+    if (sm->type == DETECT_CONTENT) {
         if (cd->flags & DETECT_CONTENT_FAST_PATTERN &&
             !(cd->flags & DETECT_CONTENT_FAST_PATTERN_ONLY) &&
             cd->flags & cd->flags & DETECT_CONTENT_FAST_PATTERN_CHOP &&
@@ -2198,7 +2198,7 @@ int DetectFastPatternTest56(void)
     result = 0;
     sm = de_ctx->sig_list->sm_lists[DETECT_SM_LIST_UMATCH];
     DetectContentData *ud = sm->ctx;
-    if (sm != NULL && sm->type == DETECT_URICONTENT) {
+    if (sm->type == DETECT_URICONTENT) {
         if (ud->flags & DETECT_CONTENT_FAST_PATTERN &&
             ud->flags & DETECT_CONTENT_FAST_PATTERN_ONLY &&
             !(ud->flags & DETECT_CONTENT_FAST_PATTERN_CHOP) &&
@@ -2234,7 +2234,7 @@ int DetectFastPatternTest57(void)
     result = 0;
     sm = de_ctx->sig_list->sm_lists[DETECT_SM_LIST_UMATCH];
     DetectContentData *ud = sm->ctx;
-    if (sm != NULL && sm->type == DETECT_URICONTENT) {
+    if (sm->type == DETECT_URICONTENT) {
         if (ud->flags & DETECT_CONTENT_FAST_PATTERN &&
             !(ud->flags & DETECT_CONTENT_FAST_PATTERN_ONLY) &&
             ud->flags & DETECT_CONTENT_FAST_PATTERN_CHOP &&
@@ -3279,7 +3279,7 @@ int DetectFastPatternTest96(void)
     result = 0;
     sm = de_ctx->sig_list->sm_lists[DETECT_SM_LIST_UMATCH];
     DetectContentData *ud = sm->ctx;
-    if (sm != NULL && sm->type == DETECT_URICONTENT) {
+    if (sm->type == DETECT_URICONTENT) {
         if (ud->flags & DETECT_CONTENT_FAST_PATTERN &&
             ud->flags & DETECT_CONTENT_FAST_PATTERN_ONLY &&
             !(ud->flags & DETECT_CONTENT_FAST_PATTERN_CHOP) &&
@@ -3315,7 +3315,7 @@ int DetectFastPatternTest97(void)
     result = 0;
     sm = de_ctx->sig_list->sm_lists[DETECT_SM_LIST_UMATCH];
     DetectContentData *ud = sm->ctx;
-    if (sm != NULL && sm->type == DETECT_URICONTENT) {
+    if (sm->type == DETECT_URICONTENT) {
         if (ud->flags & DETECT_CONTENT_FAST_PATTERN &&
             !(ud->flags & DETECT_CONTENT_FAST_PATTERN_ONLY) &&
             ud->flags & DETECT_CONTENT_FAST_PATTERN_CHOP &&
@@ -4382,16 +4382,14 @@ int DetectFastPatternTest137(void)
     result = 0;
     sm = de_ctx->sig_list->sm_lists[DETECT_SM_LIST_HCBDMATCH];
     DetectContentData *ud = sm->ctx;
-    if (sm != NULL) {
-        if (ud->flags & DETECT_CONTENT_FAST_PATTERN &&
+    if (ud->flags & DETECT_CONTENT_FAST_PATTERN &&
             ud->flags & DETECT_CONTENT_FAST_PATTERN_ONLY &&
             !(ud->flags & DETECT_CONTENT_FAST_PATTERN_CHOP) &&
             ud->fp_chop_offset == 0 &&
             ud->fp_chop_len == 0) {
-            result = 1;
-        } else {
-            result = 0;
-        }
+        result = 1;
+    } else {
+        result = 0;
     }
 
  end:
@@ -4418,16 +4416,14 @@ int DetectFastPatternTest138(void)
     result = 0;
     sm = de_ctx->sig_list->sm_lists[DETECT_SM_LIST_HCBDMATCH];
     DetectContentData *ud = sm->ctx;
-    if (sm != NULL) {
-        if (ud->flags & DETECT_CONTENT_FAST_PATTERN &&
+    if (ud->flags & DETECT_CONTENT_FAST_PATTERN &&
             !(ud->flags & DETECT_CONTENT_FAST_PATTERN_ONLY) &&
             ud->flags & DETECT_CONTENT_FAST_PATTERN_CHOP &&
             ud->fp_chop_offset == 3 &&
             ud->fp_chop_len == 4) {
-            result = 1;
-        } else {
-            result = 0;
-        }
+        result = 1;
+    } else {
+        result = 0;
     }
 
  end:
@@ -5577,16 +5573,14 @@ int DetectFastPatternTest182(void)
     result = 0;
     sm = de_ctx->sig_list->sm_lists[DETECT_SM_LIST_HHDMATCH];
     DetectContentData *ud = sm->ctx;
-    if (sm != NULL) {
-        if (ud->flags & DETECT_CONTENT_FAST_PATTERN &&
+    if (ud->flags & DETECT_CONTENT_FAST_PATTERN &&
             ud->flags & DETECT_CONTENT_FAST_PATTERN_ONLY &&
             !(ud->flags & DETECT_CONTENT_FAST_PATTERN_CHOP) &&
             ud->fp_chop_offset == 0 &&
             ud->fp_chop_len == 0) {
-            result = 1;
-        } else {
-            result = 0;
-        }
+        result = 1;
+    } else {
+        result = 0;
     }
 
  end:
@@ -5613,16 +5607,14 @@ int DetectFastPatternTest183(void)
     result = 0;
     sm = de_ctx->sig_list->sm_lists[DETECT_SM_LIST_HHDMATCH];
     DetectContentData *ud = sm->ctx;
-    if (sm != NULL) {
-        if (ud->flags & DETECT_CONTENT_FAST_PATTERN &&
+    if (ud->flags & DETECT_CONTENT_FAST_PATTERN &&
             !(ud->flags & DETECT_CONTENT_FAST_PATTERN_ONLY) &&
             ud->flags & DETECT_CONTENT_FAST_PATTERN_CHOP &&
             ud->fp_chop_offset == 3 &&
             ud->fp_chop_len == 4) {
-            result = 1;
-        } else {
-            result = 0;
-        }
+        result = 1;
+    } else {
+        result = 0;
     }
 
  end:
@@ -6696,16 +6688,14 @@ int DetectFastPatternTest223(void)
     result = 0;
     sm = de_ctx->sig_list->sm_lists[DETECT_SM_LIST_HRHDMATCH];
     DetectContentData *ud = sm->ctx;
-    if (sm != NULL) {
-        if (ud->flags & DETECT_CONTENT_FAST_PATTERN &&
+    if (ud->flags & DETECT_CONTENT_FAST_PATTERN &&
             ud->flags & DETECT_CONTENT_FAST_PATTERN_ONLY &&
             !(ud->flags & DETECT_CONTENT_FAST_PATTERN_CHOP) &&
             ud->fp_chop_offset == 0 &&
             ud->fp_chop_len == 0) {
-            result = 1;
-        } else {
-            result = 0;
-        }
+        result = 1;
+    } else {
+        result = 0;
     }
 
  end:
@@ -6732,16 +6722,14 @@ int DetectFastPatternTest224(void)
     result = 0;
     sm = de_ctx->sig_list->sm_lists[DETECT_SM_LIST_HRHDMATCH];
     DetectContentData *ud = sm->ctx;
-    if (sm != NULL) {
-        if (ud->flags & DETECT_CONTENT_FAST_PATTERN &&
+    if (ud->flags & DETECT_CONTENT_FAST_PATTERN &&
             !(ud->flags & DETECT_CONTENT_FAST_PATTERN_ONLY) &&
             ud->flags & DETECT_CONTENT_FAST_PATTERN_CHOP &&
             ud->fp_chop_offset == 3 &&
             ud->fp_chop_len == 4) {
-            result = 1;
-        } else {
-            result = 0;
-        }
+        result = 1;
+    } else {
+        result = 0;
     }
 
  end:
@@ -7819,16 +7807,14 @@ int DetectFastPatternTest264(void)
     result = 0;
     sm = de_ctx->sig_list->sm_lists[DETECT_SM_LIST_HMDMATCH];
     DetectContentData *ud = sm->ctx;
-    if (sm != NULL) {
-        if (ud->flags & DETECT_CONTENT_FAST_PATTERN &&
+    if (ud->flags & DETECT_CONTENT_FAST_PATTERN &&
             ud->flags & DETECT_CONTENT_FAST_PATTERN_ONLY &&
             !(ud->flags & DETECT_CONTENT_FAST_PATTERN_CHOP) &&
             ud->fp_chop_offset == 0 &&
             ud->fp_chop_len == 0) {
-            result = 1;
-        } else {
-            result = 0;
-        }
+        result = 1;
+    } else {
+        result = 0;
     }
 
  end:
@@ -7855,16 +7841,14 @@ int DetectFastPatternTest265(void)
     result = 0;
     sm = de_ctx->sig_list->sm_lists[DETECT_SM_LIST_HMDMATCH];
     DetectContentData *ud = sm->ctx;
-    if (sm != NULL) {
-        if (ud->flags & DETECT_CONTENT_FAST_PATTERN &&
+    if (ud->flags & DETECT_CONTENT_FAST_PATTERN &&
             !(ud->flags & DETECT_CONTENT_FAST_PATTERN_ONLY) &&
             ud->flags & DETECT_CONTENT_FAST_PATTERN_CHOP &&
             ud->fp_chop_offset == 3 &&
             ud->fp_chop_len == 4) {
-            result = 1;
-        } else {
-            result = 0;
-        }
+        result = 1;
+    } else {
+        result = 0;
     }
 
  end:
@@ -8937,16 +8921,14 @@ int DetectFastPatternTest305(void)
     result = 0;
     sm = de_ctx->sig_list->sm_lists[DETECT_SM_LIST_HCDMATCH];
     DetectContentData *ud = sm->ctx;
-    if (sm != NULL) {
-        if (ud->flags & DETECT_CONTENT_FAST_PATTERN &&
+    if (ud->flags & DETECT_CONTENT_FAST_PATTERN &&
             ud->flags & DETECT_CONTENT_FAST_PATTERN_ONLY &&
             !(ud->flags & DETECT_CONTENT_FAST_PATTERN_CHOP) &&
             ud->fp_chop_offset == 0 &&
             ud->fp_chop_len == 0) {
-            result = 1;
-        } else {
-            result = 0;
-        }
+        result = 1;
+    } else {
+        result = 0;
     }
 
  end:
@@ -8973,16 +8955,14 @@ int DetectFastPatternTest306(void)
     result = 0;
     sm = de_ctx->sig_list->sm_lists[DETECT_SM_LIST_HCDMATCH];
     DetectContentData *ud = sm->ctx;
-    if (sm != NULL) {
-        if (ud->flags & DETECT_CONTENT_FAST_PATTERN &&
+    if (ud->flags & DETECT_CONTENT_FAST_PATTERN &&
             !(ud->flags & DETECT_CONTENT_FAST_PATTERN_ONLY) &&
             ud->flags & DETECT_CONTENT_FAST_PATTERN_CHOP &&
             ud->fp_chop_offset == 3 &&
             ud->fp_chop_len == 4) {
-            result = 1;
-        } else {
-            result = 0;
-        }
+        result = 1;
+    } else {
+        result = 0;
     }
 
  end:
@@ -10062,16 +10042,14 @@ int DetectFastPatternTest346(void)
     result = 0;
     sm = de_ctx->sig_list->sm_lists[DETECT_SM_LIST_HRUDMATCH];
     DetectContentData *ud = sm->ctx;
-    if (sm != NULL) {
-        if (ud->flags & DETECT_CONTENT_FAST_PATTERN &&
+    if (ud->flags & DETECT_CONTENT_FAST_PATTERN &&
             ud->flags & DETECT_CONTENT_FAST_PATTERN_ONLY &&
             !(ud->flags & DETECT_CONTENT_FAST_PATTERN_CHOP) &&
             ud->fp_chop_offset == 0 &&
             ud->fp_chop_len == 0) {
-            result = 1;
-        } else {
-            result = 0;
-        }
+        result = 1;
+    } else {
+        result = 0;
     }
 
  end:
@@ -10098,16 +10076,14 @@ int DetectFastPatternTest347(void)
     result = 0;
     sm = de_ctx->sig_list->sm_lists[DETECT_SM_LIST_HRUDMATCH];
     DetectContentData *ud = sm->ctx;
-    if (sm != NULL) {
-        if (ud->flags & DETECT_CONTENT_FAST_PATTERN &&
+    if (ud->flags & DETECT_CONTENT_FAST_PATTERN &&
             !(ud->flags & DETECT_CONTENT_FAST_PATTERN_ONLY) &&
             ud->flags & DETECT_CONTENT_FAST_PATTERN_CHOP &&
             ud->fp_chop_offset == 3 &&
             ud->fp_chop_len == 4) {
-            result = 1;
-        } else {
-            result = 0;
-        }
+        result = 1;
+    } else {
+        result = 0;
     }
 
  end:
index 6f023ed3e03140a61921f1173484f7d0db3f0620..6ec4c65319a747600293bf4d92f075e21074cd0c 100644 (file)
@@ -268,27 +268,29 @@ static int DetectIPProtoSetup(DetectEngineCtx *de_ctx, Signature *s, char *optst
                     }
                     temp_sm = temp_sm->next;
                 }
-                DetectIPProtoData *data_temp = temp_sm->ctx;
-                if (data_temp->proto <= data->proto) {
-                    SCLogError(SC_ERR_INVALID_SIGNATURE, "We can't use a have "
-                               "both gt and lt ipprotos, with the lt being "
-                               "lower than gt value");
-                    goto error;
-                    /* Updated by AS.  Please do not remove this unused code.  Need it
-                     * as we redo this code once we solve ipproto multiple uses */
+                if (temp_sm != NULL) {
+                    DetectIPProtoData *data_temp = temp_sm->ctx;
+                    if (data_temp->proto <= data->proto) {
+                        SCLogError(SC_ERR_INVALID_SIGNATURE, "We can't use a have "
+                                "both gt and lt ipprotos, with the lt being "
+                                "lower than gt value");
+                        goto error;
+                        /* Updated by AS.  Please do not remove this unused code.  Need it
+                         * as we redo this code once we solve ipproto multiple uses */
 #if 0
-                    s->proto.proto[data->proto / 8] |= 0xfe << (data->proto % 8);
-                    for (i = (data->proto / 8) + 1; i < (256 / 8); i++) {
-                        s->proto.proto[i] = 0xff;
-                    }
+                        s->proto.proto[data->proto / 8] |= 0xfe << (data->proto % 8);
+                        for (i = (data->proto / 8) + 1; i < (256 / 8); i++) {
+                            s->proto.proto[i] = 0xff;
+                        }
 #endif
-                } else {
-                    for (i = 0; i < (data->proto / 8); i++) {
-                        s->proto.proto[i] = 0;
-                    }
-                    s->proto.proto[data->proto / 8] &= 0xfe << (data->proto % 8);
-                    for (i = (data->proto / 8) + 1; i < (256 / 8); i++) {
-                        s->proto.proto[i] &= 0xff;
+                    } else {
+                        for (i = 0; i < (data->proto / 8); i++) {
+                            s->proto.proto[i] = 0;
+                        }
+                        s->proto.proto[data->proto / 8] &= 0xfe << (data->proto % 8);
+                        for (i = (data->proto / 8) + 1; i < (256 / 8); i++) {
+                            s->proto.proto[i] &= 0xff;
+                        }
                     }
                 }
             } else if (!lt_set && not_set) {
@@ -309,48 +311,50 @@ static int DetectIPProtoSetup(DetectEngineCtx *de_ctx, Signature *s, char *optst
                     }
                     temp_sm = temp_sm->next;
                 }
-                data_temp = temp_sm->ctx;
-                if (data_temp->proto <= data->proto) {
-                    /* Updated by AS.  Please do not remove this unused code.
-                     * Need it as we redo this code once we solve ipproto
-                     * multiple uses */
-                    SCLogError(SC_ERR_INVALID_SIGNATURE, "We can't use a have "
-                               "both gt and lt ipprotos, with the lt being "
-                               "lower than gt value");
-                    goto error;
+                if (temp_sm != NULL) {
+                    data_temp = temp_sm->ctx;
+                    if (data_temp->proto <= data->proto) {
+                        /* Updated by AS.  Please do not remove this unused code.
+                         * Need it as we redo this code once we solve ipproto
+                         * multiple uses */
+                        SCLogError(SC_ERR_INVALID_SIGNATURE, "We can't use a have "
+                                "both gt and lt ipprotos, with the lt being "
+                                "lower than gt value");
+                        goto error;
 #if 0
-                    s->proto.proto[data->proto / 8] |= 0xfe << (data->proto % 8);
-                    for (i = (data->proto / 8) + 1; i < (256 / 8); i++) {
-                        s->proto.proto[i] = 0xff;
-                    }
-                    temp_sm = s->sm_lists[DETECT_SM_LIST_MATCH];
-                    uint8_t *not_protos = NULL;
-                    int not_protos_len = 0;
-                    while (temp_sm != NULL) {
-                        if (temp_sm->type == DETECT_IPPROTO &&
-                            ((DetectIPProtoData *)temp_sm->ctx)->op == DETECT_IPPROTO_OP_NOT) {
-                            DetectIPProtoData *data_temp = temp_sm->ctx;
-                            not_protos = SCRealloc(not_protos,
-                                                   (not_protos_len + 1) * sizeof(uint8_t));
-                            if (not_protos == NULL)
-                                goto error;
-                            not_protos[not_protos_len] = data_temp->proto;
-                            not_protos_len++;
+                        s->proto.proto[data->proto / 8] |= 0xfe << (data->proto % 8);
+                        for (i = (data->proto / 8) + 1; i < (256 / 8); i++) {
+                            s->proto.proto[i] = 0xff;
                         }
-                        temp_sm = temp_sm->next;
-                    }
-                    qsort(not_protos, not_protos_len, sizeof(uint8_t),
-                          DetectIPProtoQSortCompare);
-                    int j = 0;
-                    while (j < not_protos_len) {
-                        if (not_protos[j] < data->proto) {
-                            ;
-                        } else {
-                            s->proto.proto[not_protos[j] / 8] &= ~(1 << (not_protos[j] % 8));
+                        temp_sm = s->sm_lists[DETECT_SM_LIST_MATCH];
+                        uint8_t *not_protos = NULL;
+                        int not_protos_len = 0;
+                        while (temp_sm != NULL) {
+                            if (temp_sm->type == DETECT_IPPROTO &&
+                                    ((DetectIPProtoData *)temp_sm->ctx)->op == DETECT_IPPROTO_OP_NOT) {
+                                DetectIPProtoData *data_temp = temp_sm->ctx;
+                                not_protos = SCRealloc(not_protos,
+                                        (not_protos_len + 1) * sizeof(uint8_t));
+                                if (not_protos == NULL)
+                                    goto error;
+                                not_protos[not_protos_len] = data_temp->proto;
+                                not_protos_len++;
+                            }
+                            temp_sm = temp_sm->next;
+                        }
+                        qsort(not_protos, not_protos_len, sizeof(uint8_t),
+                                DetectIPProtoQSortCompare);
+                        int j = 0;
+                        while (j < not_protos_len) {
+                            if (not_protos[j] < data->proto) {
+                                ;
+                            } else {
+                                s->proto.proto[not_protos[j] / 8] &= ~(1 << (not_protos[j] % 8));
+                            }
+                            j++;
                         }
-                        j++;
-                    }
 #endif
+                    }
                 } else {
                     for (i = 0; i < (data->proto / 8); i++) {
                         s->proto.proto[i] = 0;
@@ -383,28 +387,30 @@ static int DetectIPProtoSetup(DetectEngineCtx *de_ctx, Signature *s, char *optst
                     }
                     temp_sm = temp_sm->next;
                 }
-                DetectIPProtoData *data_temp = temp_sm->ctx;
-                if (data_temp->proto >= data->proto) {
-                    /* Updated by AS.  Please do not remove this unused code.
-                     * Need it as we redo this code once we solve ipproto
-                     * multiple uses */
-                    SCLogError(SC_ERR_INVALID_SIGNATURE, "We can't use a have "
-                               "both gt and lt ipprotos, with the lt being "
-                               "lower than gt value");
-                    goto error;
+                if (temp_sm != NULL) {
+                    DetectIPProtoData *data_temp = temp_sm->ctx;
+                    if (data_temp->proto >= data->proto) {
+                        /* Updated by AS.  Please do not remove this unused code.
+                         * Need it as we redo this code once we solve ipproto
+                         * multiple uses */
+                        SCLogError(SC_ERR_INVALID_SIGNATURE, "We can't use a have "
+                                "both gt and lt ipprotos, with the lt being "
+                                "lower than gt value");
+                        goto error;
 #if 0
-                    for (i = 0; i < (data->proto / 8); i++) {
-                        s->proto.proto[i] = 0xff;
-                    }
-                    s->proto.proto[data->proto / 8] |= ~(0xff << (data->proto % 8));;
+                        for (i = 0; i < (data->proto / 8); i++) {
+                            s->proto.proto[i] = 0xff;
+                        }
+                        s->proto.proto[data->proto / 8] |= ~(0xff << (data->proto % 8));;
 #endif
-                } else {
-                    for (i = 0; i < (data->proto / 8); i++) {
-                        s->proto.proto[i] &= 0xff;
-                    }
-                    s->proto.proto[data->proto / 8] &= ~(0xff << (data->proto % 8));
-                    for (i = (data->proto / 8) + 1; i < 256 / 8; i++) {
-                        s->proto.proto[i] = 0;
+                    } else {
+                        for (i = 0; i < (data->proto / 8); i++) {
+                            s->proto.proto[i] &= 0xff;
+                        }
+                        s->proto.proto[data->proto / 8] &= ~(0xff << (data->proto % 8));
+                        for (i = (data->proto / 8) + 1; i < 256 / 8; i++) {
+                            s->proto.proto[i] = 0;
+                        }
                     }
                 }
             } else if (!gt_set && not_set) {
@@ -425,48 +431,50 @@ static int DetectIPProtoSetup(DetectEngineCtx *de_ctx, Signature *s, char *optst
                     }
                     temp_sm = temp_sm->next;
                 }
-                data_temp = temp_sm->ctx;
-                if (data_temp->proto >= data->proto) {
-                    /* Updated by AS.  Please do not remove this unused code.
-                     * Need it as we redo this code once we solve ipproto
-                     * multiple uses */
-                    SCLogError(SC_ERR_INVALID_SIGNATURE, "We can't use a have "
-                               "both gt and lt ipprotos, with the lt being "
-                               "lower than gt value");
-                    goto error;
+                if (temp_sm != NULL) {
+                    data_temp = temp_sm->ctx;
+                    if (data_temp->proto >= data->proto) {
+                        /* Updated by AS.  Please do not remove this unused code.
+                         * Need it as we redo this code once we solve ipproto
+                         * multiple uses */
+                        SCLogError(SC_ERR_INVALID_SIGNATURE, "We can't use a have "
+                                "both gt and lt ipprotos, with the lt being "
+                                "lower than gt value");
+                        goto error;
 #if 0
-                    for (i = 0; i < (data->proto / 8); i++) {
-                        s->proto.proto[i] = 0xff;
-                    }
-                    s->proto.proto[data->proto / 8] |= ~(0xff << (data->proto % 8));
-                    temp_sm = s->sm_lists[DETECT_SM_LIST_MATCH];
-                    uint8_t *not_protos = NULL;
-                    int not_protos_len = 0;
-                    while (temp_sm != NULL) {
-                        if (temp_sm->type == DETECT_IPPROTO &&
-                            ((DetectIPProtoData *)temp_sm->ctx)->op == DETECT_IPPROTO_OP_NOT) {
-                            DetectIPProtoData *data_temp = temp_sm->ctx;
-                            not_protos = SCRealloc(not_protos,
-                                                   (not_protos_len + 1) * sizeof(uint8_t));
-                            if (not_protos == NULL)
-                                goto error;
-                            not_protos[not_protos_len] = data_temp->proto;
-                            not_protos_len++;
+                        for (i = 0; i < (data->proto / 8); i++) {
+                            s->proto.proto[i] = 0xff;
                         }
-                        temp_sm = temp_sm->next;
-                    }
-                    qsort(not_protos, not_protos_len, sizeof(uint8_t),
-                          DetectIPProtoQSortCompare);
-                    int j = 0;
-                    while (j < not_protos_len) {
-                        if (not_protos[j] < data->proto) {
-                            s->proto.proto[not_protos[j] / 8] &= ~(1 << (not_protos[j] % 8));
-                        } else {
-                            ;
+                        s->proto.proto[data->proto / 8] |= ~(0xff << (data->proto % 8));
+                        temp_sm = s->sm_lists[DETECT_SM_LIST_MATCH];
+                        uint8_t *not_protos = NULL;
+                        int not_protos_len = 0;
+                        while (temp_sm != NULL) {
+                            if (temp_sm->type == DETECT_IPPROTO &&
+                                    ((DetectIPProtoData *)temp_sm->ctx)->op == DETECT_IPPROTO_OP_NOT) {
+                                DetectIPProtoData *data_temp = temp_sm->ctx;
+                                not_protos = SCRealloc(not_protos,
+                                        (not_protos_len + 1) * sizeof(uint8_t));
+                                if (not_protos == NULL)
+                                    goto error;
+                                not_protos[not_protos_len] = data_temp->proto;
+                                not_protos_len++;
+                            }
+                            temp_sm = temp_sm->next;
+                        }
+                        qsort(not_protos, not_protos_len, sizeof(uint8_t),
+                                DetectIPProtoQSortCompare);
+                        int j = 0;
+                        while (j < not_protos_len) {
+                            if (not_protos[j] < data->proto) {
+                                s->proto.proto[not_protos[j] / 8] &= ~(1 << (not_protos[j] % 8));
+                            } else {
+                                ;
+                            }
+                            j++;
                         }
-                        j++;
-                    }
 #endif
+                    }
                 } else {
                     for (i = 0; i < (data->proto / 8); i++) {
                         s->proto.proto[i] &= 0xFF;
index b42bf3062412a7bd5b7dc60c3d9c089ef1d0fd28..f325cdcde70c0cd6f1f5ff33f4b878e5ea7b944f 100644 (file)
@@ -215,7 +215,8 @@ void PoolPrintSaturation(Pool *p) {
  */
 
 void *PoolTestAlloc(void *allocdata) {
-    return SCMalloc(10);
+    void *ptr = SCMalloc(10);
+    return ptr;
 }
 void *PoolTestAllocArg(void *allocdata) {
     size_t len = strlen((char *)allocdata) + 1;