From: Anoop Saldanha Date: Thu, 3 May 2012 07:05:53 +0000 (+0530) Subject: more coverity fixes X-Git-Tag: suricata-1.3beta2~56 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bff2866aedf8912fe00da933a0546a9b9a54f195;p=thirdparty%2Fsuricata.git more coverity fixes --- diff --git a/src/app-layer-dcerpc-udp.c b/src/app-layer-dcerpc-udp.c index df244cd718..950d333c10 100644 --- a/src/app-layer-dcerpc-udp.c +++ b/src/app-layer-dcerpc-udp.c @@ -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; diff --git a/src/app-layer-smb2.c b/src/app-layer-smb2.c index d67002875d..85b8ffdae7 100644 --- a/src/app-layer-smb2.c +++ b/src/app-layer-smb2.c @@ -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; diff --git a/src/counters.c b/src/counters.c index eae1bdfe29..bbb76a0d9d 100644 --- a/src/counters.c +++ b/src/counters.c @@ -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; diff --git a/src/detect-byte-extract.c b/src/detect-byte-extract.c index 0d6e71c495..2098b67ce5 100644 --- a/src/detect-byte-extract.c +++ b/src/detect-byte-extract.c @@ -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]; diff --git a/src/detect-engine-sigorder.c b/src/detect-engine-sigorder.c index 5e21962dfa..b4a20ac56f 100644 --- a/src/detect-engine-sigorder.c +++ b/src/detect-engine-sigorder.c @@ -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) { diff --git a/src/util-debug-filters.c b/src/util-debug-filters.c index f4c2e84dfa..72288d1623 100644 --- a/src/util-debug-filters.c +++ b/src/util-debug-filters.c @@ -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; diff --git a/src/util-debug.c b/src/util-debug.c index d71fa43a3f..620ade1f25 100644 --- a/src/util-debug.c +++ b/src/util-debug.c @@ -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;