]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
more coverity fixes
authorAnoop Saldanha <poonaatsoc@gmail.com>
Thu, 3 May 2012 07:05:53 +0000 (12:35 +0530)
committerVictor Julien <victor@inliniac.net>
Thu, 3 May 2012 07:11:02 +0000 (09:11 +0200)
src/app-layer-dcerpc-udp.c
src/app-layer-smb2.c
src/counters.c
src/detect-byte-extract.c
src/detect-engine-sigorder.c
src/util-debug-filters.c
src/util-debug.c

index df244cd71859c9c783a567ddae6648f38f028658..950d333c1018e4649ea33dcd71ece898da7876cb 100644 (file)
@@ -194,7 +194,7 @@ static int DCERPCUDPParseHeader(Flow *f, void *dcerpcudp_state,
                                        sstate->dcerpc.dcerpchdrudp.if_vers = *(p + 60);
                                        sstate->dcerpc.dcerpchdrudp.if_vers |= *(p + 61) << 8;
                                        sstate->dcerpc.dcerpchdrudp.if_vers |= *(p + 62) << 16;
-                                       sstate->dcerpc.dcerpchdrudp.if_vers |= *(p + 63) >> 24;
+                                       sstate->dcerpc.dcerpchdrudp.if_vers |= *(p + 63) << 24;
                                        sstate->dcerpc.dcerpchdrudp.seqnum = *(p + 64);
                                        sstate->dcerpc.dcerpchdrudp.seqnum |= *(p + 65) << 8;
                                        sstate->dcerpc.dcerpchdrudp.seqnum |= *(p + 66) << 16;
index d67002875dd2b2fd4a34ab4e6f0047cfb1426a10..85b8ffdae7f2af92a031c6c9ec48f81196e6eed2 100644 (file)
@@ -132,7 +132,7 @@ static uint32_t SMB2ParseHeader(void *smb2_state, AppLayerParserState *pstate,
                     sstate->smb2.MessageId = *(p + 24);
                     sstate->smb2.MessageId |= *(p + 25) << 8;
                     sstate->smb2.MessageId |= *(p + 26) << 16;
-                    sstate->smb2.MessageId |= *(p + 27) << 24;
+                    sstate->smb2.MessageId |= (uint64_t) *(p + 27) << 24;
                     sstate->smb2.MessageId |= (uint64_t) *(p + 28) << 32;
                     sstate->smb2.MessageId |= (uint64_t) *(p + 29) << 40;
                     sstate->smb2.MessageId |= (uint64_t) *(p + 30) << 48;
@@ -148,7 +148,7 @@ static uint32_t SMB2ParseHeader(void *smb2_state, AppLayerParserState *pstate,
                     sstate->smb2.SessionId = *(p + 40);
                     sstate->smb2.SessionId |= *(p + 41) << 8;
                     sstate->smb2.SessionId |= *(p + 42) << 16;
-                    sstate->smb2.SessionId |= *(p + 43) << 24;
+                    sstate->smb2.SessionId |= (uint64_t) *(p + 43) << 24;
                     sstate->smb2.SessionId |= (uint64_t) *(p + 44) << 32;
                     sstate->smb2.SessionId |= (uint64_t) *(p + 45) << 40;
                     sstate->smb2.SessionId |= (uint64_t) *(p + 46) << 48;
@@ -266,7 +266,7 @@ static uint32_t SMB2ParseHeader(void *smb2_state, AppLayerParserState *pstate,
                 sstate->smb2.MessageId = *(p++) << 16;
                 if (!(--input_len)) break;
             case 31:
-                sstate->smb2.MessageId = *(p++) << 24;
+                sstate->smb2.MessageId = (uint64_t) *(p++) << 24;
                 if (!(--input_len)) break;
             case 32:
                 sstate->smb2.MessageId = (uint64_t) *(p++) << 32;
@@ -314,7 +314,7 @@ static uint32_t SMB2ParseHeader(void *smb2_state, AppLayerParserState *pstate,
                 sstate->smb2.SessionId |= *(p++) << 16;
                 if (!(--input_len)) break;
             case 47:
-                sstate->smb2.SessionId |= *(p++) << 24;
+                sstate->smb2.SessionId |= (uint64_t) *(p++) << 24;
                 if (!(--input_len)) break;
             case 48:
                 sstate->smb2.SessionId |= (uint64_t) *(p++) << 32;
index eae1bdfe29ebde0a92f903d2408dc3aee44a700e..bbb76a0d9d0261b6d4ea7ff6ba34de547e14782e 100644 (file)
@@ -1482,14 +1482,18 @@ int SCPerfAddToClubbedTMTable(char *tm_name, SCPerfContext *pctx)
 
     /* get me the bugger who wrote this junk of a code :P */
     if (pctmi == NULL) {
-        if ( (temp = SCMalloc(sizeof(SCPerfClubTMInst))) == NULL)
+        if ( (temp = SCMalloc(sizeof(SCPerfClubTMInst))) == NULL) {
+            SCMutexUnlock(&sc_perf_op_ctx->pctmi_lock);
             return 0;
+        }
         memset(temp, 0, sizeof(SCPerfClubTMInst));
 
         temp->size = 1;
         temp->head = SCMalloc(sizeof(SCPerfContext **));
-        if (temp->head == NULL)
+        if (temp->head == NULL) {
+            SCMutexUnlock(&sc_perf_op_ctx->pctmi_lock);
             return 0;
+        }
         temp->head[0] = pctx;
         temp->tm_name = SCStrdup(tm_name);
 
@@ -1514,8 +1518,10 @@ int SCPerfAddToClubbedTMTable(char *tm_name, SCPerfContext *pctx)
 
     pctmi->head = SCRealloc(pctmi->head,
                           (pctmi->size + 1) * sizeof(SCPerfContext **));
-    if (pctmi->head == NULL)
+    if (pctmi->head == NULL) {
+        SCMutexUnlock(&sc_perf_op_ctx->pctmi_lock);
         return 0;
+    }
     hpctx = pctmi->head;
 
     hpctx[pctmi->size] = pctx;
index 0d6e71c49589532f23d49531260cb42c99f969ea..2098b67ce527658202103c5c60d463eca6c40684 100644 (file)
@@ -751,6 +751,9 @@ void DetectByteExtractFree(void *ptr)
 
 SigMatch *DetectByteExtractRetrieveSMVar(const char *arg, Signature *s, int list)
 {
+    if (list == -1)
+        return NULL;
+
     DetectByteExtractData *bed = NULL;
     SigMatch *sm = s->sm_lists[list];
 
index 5e21962dfa6f7ab8ad4e7b8c56a6d2f22d04c656..b4a20ac56fe31bc21519de74a999c56393049522 100644 (file)
@@ -185,9 +185,6 @@ static inline int SCSigGetFlowvarType(Signature *sig)
         sm = sm->next;
     }
 
-    if (type != DETECT_FLOWVAR_NOT_USED)
-        return type;
-
     sm = sig->sm_lists[DETECT_SM_LIST_MATCH];
     pd = NULL;
     while (sm != NULL) {
@@ -233,9 +230,6 @@ static inline int SCSigGetPktvarType(Signature *sig)
         sm = sm->next;
     }
 
-    if (type != DETECT_PKTVAR_NOT_USED)
-        return type;
-
     sm = sig->sm_lists[DETECT_SM_LIST_MATCH];
     pd = NULL;
     while (sm != NULL) {
index f4c2e84dfa304122d97615b995624544fc8fbbc2..72288d1623946bd8eb7034ff6cf9580cd85e3001 100644 (file)
@@ -587,8 +587,10 @@ int SCLogCheckFDFilterEntry(const char *function)
         return 1;
     }
 
-    if ( (thread_list_temp = SCMalloc(sizeof(SCLogFDFilterThreadList))) == NULL)
+    if ( (thread_list_temp = SCMalloc(sizeof(SCLogFDFilterThreadList))) == NULL) {
+        SCMutexUnlock(&sc_log_fd_filters_tl_m);
         return 0;
+    }
     memset(thread_list_temp, 0, sizeof(SCLogFDFilterThreadList));
 
     thread_list_temp->t = self;
index d71fa43a3f3e5167d8a77e1a8586a1cc6643c1ca..620ade1f2546b9649dedd1507e59435c7a948bda 100644 (file)
@@ -862,8 +862,6 @@ static inline void SCLogSetOPIface(SCLogInitData *sc_lid, SCLogConfig *sc_lc)
 
                 op_ifaces_ctx = SCLogInitSyslogOPIface(SCMapEnumNameToValue(s, SCSyslogGetFacilityMap()), NULL, -1);
                 break;
-            default:
-                break;
         }
         sc_lc->op_ifaces = op_ifaces_ctx;
         sc_lc->op_ifaces_cnt++;
@@ -1281,8 +1279,6 @@ void SCLogInitLogModuleIfEnvSet(void)
 
             op_ifaces_ctx = SCLogInitSyslogOPIface(SCMapEnumNameToValue(s, SCSyslogGetFacilityMap()), NULL, -1);
             break;
-        default:
-            break;
     }
     sc_lc->op_ifaces = op_ifaces_ctx;