Fix a number of potential issues found by CLANG and cppcheck.

remotes/origin/master-1.1.x
Victor Julien 14 years ago
parent 362c25ec8a
commit 8186565240

@ -659,7 +659,7 @@ TmEcode AlertPrelude (ThreadVars *tv, Packet *p, void *data, PacketQueue *pq, Pa
idmef_time_t *time; idmef_time_t *time;
idmef_alert_t *alert; idmef_alert_t *alert;
prelude_string_t *str; prelude_string_t *str;
idmef_message_t *idmef; idmef_message_t *idmef = NULL;
idmef_classification_t *class; idmef_classification_t *class;
PacketAlert *pa; PacketAlert *pa;
@ -748,7 +748,8 @@ TmEcode AlertPrelude (ThreadVars *tv, Packet *p, void *data, PacketQueue *pq, Pa
SCReturnInt(TM_ECODE_OK); SCReturnInt(TM_ECODE_OK);
err: err:
idmef_message_destroy(idmef); if (idmef != NULL)
idmef_message_destroy(idmef);
SCReturnInt(TM_ECODE_FAILED); SCReturnInt(TM_ECODE_FAILED);
} }

@ -1774,6 +1774,7 @@ void AppLayerRegisterProbingParser(AlpProtoDetectCtx *ctx,
{ {
AppLayerProbingParser **probing_parsers = &ctx->probing_parsers; AppLayerProbingParser **probing_parsers = &ctx->probing_parsers;
AppLayerProbingParserElement *pe = NULL; AppLayerProbingParserElement *pe = NULL;
AppLayerProbingParserElement *new_pe = NULL;
AppLayerProbingParser *pp = NULL; AppLayerProbingParser *pp = NULL;
/* Add info about this probing parser to our database. Also detects any /* 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 */ /* \todo introduce parsing port range here */
/* Get a new parser element */ /* Get a new parser element */
AppLayerProbingParserElement *new_pe = new_pe = AppLayerCreateAppLayerProbingParserElement(al_proto_name, ip_proto,
AppLayerCreateAppLayerProbingParserElement(al_proto_name, ip_proto,
al_proto, min_depth, al_proto, min_depth,
max_depth, port, max_depth, port,
priority, top, priority, top,

@ -400,28 +400,26 @@ static void SCPerfReleaseOPCtx()
SCPerfClubTMInst *temp = NULL; SCPerfClubTMInst *temp = NULL;
pctmi = sc_perf_op_ctx->pctmi; pctmi = sc_perf_op_ctx->pctmi;
if (sc_perf_op_ctx != NULL) { if (sc_perf_op_ctx->fp != NULL)
if (sc_perf_op_ctx->fp != NULL) fclose(sc_perf_op_ctx->fp);
fclose(sc_perf_op_ctx->fp);
if (sc_perf_op_ctx->file != NULL) if (sc_perf_op_ctx->file != NULL)
SCFree(sc_perf_op_ctx->file); SCFree(sc_perf_op_ctx->file);
while (pctmi != NULL) { while (pctmi != NULL) {
if (pctmi->tm_name != NULL) if (pctmi->tm_name != NULL)
SCFree(pctmi->tm_name); SCFree(pctmi->tm_name);
if (pctmi->head != NULL) if (pctmi->head != NULL)
SCFree(pctmi->head); SCFree(pctmi->head);
temp = pctmi->next; temp = pctmi->next;
SCFree(pctmi); SCFree(pctmi);
pctmi = temp; pctmi = temp;
}
SCFree(sc_perf_op_ctx);
} }
SCFree(sc_perf_op_ctx);
return; return;
} }

@ -103,10 +103,6 @@ void DecodeGRE(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p, uint8_t *pkt, u
if (GRE_FLAG_ISSET_ROUTE(p->greh)) if (GRE_FLAG_ISSET_ROUTE(p->greh))
{ {
gsre = (GRESreHdr *)(pkt + header_len);
if (gsre == NULL)
return;
while (1) while (1)
{ {
if ((header_len + GRE_SRE_HDR_LEN) > len) { 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; return;
} }
gsre = (GRESreHdr *)(pkt + header_len);
header_len += GRE_SRE_HDR_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; break;
header_len += gsre->sre_length; 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); ENGINE_SET_EVENT(p, GRE_VERSION0_MALFORMED_SRE_HDR);
return; return;
} }
gsre = (GRESreHdr *)(pkt + header_len);
if (gsre == NULL)
return;
} }
} }
break; break;

@ -606,13 +606,18 @@ int DetectAddressJoinIPv4(DetectEngineCtx *de_ctx, DetectAddress *target,
static int DetectAddressIPv4TestAddressCmp01(void) static int DetectAddressIPv4TestAddressCmp01(void)
{ {
DetectAddress *a = DetectAddressInit();
DetectAddress *b = DetectAddressInit();
struct in_addr in; struct in_addr in;
int result = 1; int result = 1;
if (a == NULL || b == NULL) DetectAddress *a = DetectAddressInit();
goto error; 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) if (inet_pton(AF_INET, "1.2.3.4", &in) < 0)
goto error; goto error;
@ -1036,17 +1041,13 @@ static int DetectAddressIPv4TestAddressCmp01(void)
b->ip2.addr_data32[0] = in.s_addr; b->ip2.addr_data32[0] = in.s_addr;
result &= (DetectAddressCmpIPv4(a, b) != ADDRESS_GT); result &= (DetectAddressCmpIPv4(a, b) != ADDRESS_GT);
if (a != NULL) DetectAddressFree(a);
DetectAddressFree(a); DetectAddressFree(b);
if (b != NULL)
DetectAddressFree(b);
return result; return result;
error: error:
if (a != NULL) DetectAddressFree(a);
DetectAddressFree(a); DetectAddressFree(b);
if (b != NULL)
DetectAddressFree(b);
return 0; return 0;
} }
@ -1255,12 +1256,11 @@ static int DetectAddressIPv4IsCompleteIPSpace04(void)
static int DetectAddressIPv4CutNot05(void) static int DetectAddressIPv4CutNot05(void)
{ {
DetectAddress *a = NULL; DetectAddress *a = NULL;
DetectAddress *b = NULL;
struct in_addr in; struct in_addr in;
int result = 1; int result = 1;
if ( (a = DetectAddressInit()) == NULL) if ( (a = DetectAddressInit()) == NULL)
goto error; return 0;
if (inet_pton(AF_INET, "0.0.0.0", &in) < 0) if (inet_pton(AF_INET, "0.0.0.0", &in) < 0)
goto error; goto error;
@ -1270,29 +1270,22 @@ static int DetectAddressIPv4CutNot05(void)
a->ip2.addr_data32[0] = in.s_addr; a->ip2.addr_data32[0] = in.s_addr;
result &= (DetectAddressCutNotIPv4(a, &b) == -1); result &= (DetectAddressCutNotIPv4(a, &b) == -1);
if (a != NULL) DetectAddressFree(a);
DetectAddressFree(a);
if (b != NULL)
DetectAddressFree(b);
return result; return result;
error: error:
if (a != NULL) DetectAddressFree(a);
DetectAddressFree(a);
if (b != NULL)
DetectAddressFree(b);
return 0; return 0;
} }
static int DetectAddressIPv4CutNot06(void) static int DetectAddressIPv4CutNot06(void)
{ {
DetectAddress *a = NULL; DetectAddress *a = NULL;
DetectAddress *b = NULL;
struct in_addr in; struct in_addr in;
int result = 1; int result = 1;
if ( (a = DetectAddressInit()) == NULL) if ( (a = DetectAddressInit()) == NULL)
goto error; return 0;
if (inet_pton(AF_INET, "0.0.0.0", &in) < 0) if (inet_pton(AF_INET, "0.0.0.0", &in) < 0)
goto error; goto error;
@ -1308,31 +1301,23 @@ static int DetectAddressIPv4CutNot06(void)
if (inet_pton(AF_INET, "255.255.255.255", &in) < 0) if (inet_pton(AF_INET, "255.255.255.255", &in) < 0)
goto error; goto error;
result &= (a->ip2.addr_data32[0] = in.s_addr); result &= (a->ip2.addr_data32[0] = in.s_addr);
result &= (b == NULL);
if (a != NULL) DetectAddressFree(a);
DetectAddressFree(a);
if (b != NULL)
DetectAddressFree(b);
return result; return result;
error: error:
if (a != NULL) DetectAddressFree(a);
DetectAddressFree(a);
if (b != NULL)
DetectAddressFree(b);
return 0; return 0;
} }
static int DetectAddressIPv4CutNot07(void) static int DetectAddressIPv4CutNot07(void)
{ {
DetectAddress *a = NULL; DetectAddress *a = NULL;
DetectAddress *b = NULL;
struct in_addr in; struct in_addr in;
int result = 1; int result = 1;
if ( (a = DetectAddressInit()) == NULL) if ( (a = DetectAddressInit()) == NULL)
goto error; return 0;
if (inet_pton(AF_INET, "1.2.3.4", &in) < 0) if (inet_pton(AF_INET, "1.2.3.4", &in) < 0)
goto error; goto error;
@ -1348,19 +1333,12 @@ static int DetectAddressIPv4CutNot07(void)
if (inet_pton(AF_INET, "1.2.3.3", &in) < 0) if (inet_pton(AF_INET, "1.2.3.3", &in) < 0)
goto error; goto error;
result &= (a->ip2.addr_data32[0] = in.s_addr); result &= (a->ip2.addr_data32[0] = in.s_addr);
result &= (b == NULL);
if (a != NULL) DetectAddressFree(a);
DetectAddressFree(a);
if (b != NULL)
DetectAddressFree(b);
return result; return result;
error: error:
if (a != NULL) DetectAddressFree(a);
DetectAddressFree(a);
if (b != NULL)
DetectAddressFree(b);
return 0; return 0;
} }
@ -1372,7 +1350,7 @@ static int DetectAddressIPv4CutNot08(void)
int result = 1; int result = 1;
if ( (a = DetectAddressInit()) == NULL) if ( (a = DetectAddressInit()) == NULL)
goto error; return 0;
if (inet_pton(AF_INET, "1.2.3.4", &in) < 0) if (inet_pton(AF_INET, "1.2.3.4", &in) < 0)
goto error; goto error;
@ -1402,15 +1380,13 @@ static int DetectAddressIPv4CutNot08(void)
goto error; goto error;
result &= (b->ip2.addr_data32[0] = in.s_addr); result &= (b->ip2.addr_data32[0] = in.s_addr);
if (a != NULL) DetectAddressFree(a);
DetectAddressFree(a);
if (b != NULL) if (b != NULL)
DetectAddressFree(b); DetectAddressFree(b);
return result; return result;
error: error:
if (a != NULL) DetectAddressFree(a);
DetectAddressFree(a);
if (b != NULL) if (b != NULL)
DetectAddressFree(b); DetectAddressFree(b);
return 0; return 0;
@ -1424,7 +1400,7 @@ static int DetectAddressIPv4CutNot09(void)
int result = 1; int result = 1;
if ( (a = DetectAddressInit()) == NULL) if ( (a = DetectAddressInit()) == NULL)
goto error; return 0;
if (inet_pton(AF_INET, "1.2.3.4", &in) < 0) if (inet_pton(AF_INET, "1.2.3.4", &in) < 0)
goto error; goto error;
@ -1454,15 +1430,13 @@ static int DetectAddressIPv4CutNot09(void)
goto error; goto error;
result &= (b->ip2.addr_data32[0] = in.s_addr); result &= (b->ip2.addr_data32[0] = in.s_addr);
if (a != NULL) DetectAddressFree(a);
DetectAddressFree(a);
if (b != NULL) if (b != NULL)
DetectAddressFree(b); DetectAddressFree(b);
return result; return result;
error: error:
if (a != NULL) DetectAddressFree(a);
DetectAddressFree(a);
if (b != NULL) if (b != NULL)
DetectAddressFree(b); DetectAddressFree(b);
return 0; return 0;
@ -1470,13 +1444,18 @@ static int DetectAddressIPv4CutNot09(void)
static int DetectAddressIPv4Join10(void) static int DetectAddressIPv4Join10(void)
{ {
DetectAddress *source = DetectAddressInit();
DetectAddress *target = DetectAddressInit();
struct in_addr in; struct in_addr in;
int result = 1; int result = 1;
if (source == NULL || target == NULL) DetectAddress *source = DetectAddressInit();
goto error; 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) if (inet_pton(AF_INET, "128.51.61.124", &in) < 0)
goto error; goto error;
@ -1588,17 +1567,13 @@ static int DetectAddressIPv4Join10(void)
goto error; goto error;
result &= (target->ip2.addr_data32[0] == in.s_addr); result &= (target->ip2.addr_data32[0] == in.s_addr);
if (source != NULL) DetectAddressFree(source);
DetectAddressFree(source); DetectAddressFree(target);
if (target != NULL)
DetectAddressFree(target);
return result; return result;
error: error:
if (source != NULL) DetectAddressFree(source);
DetectAddressFree(source); DetectAddressFree(target);
if (target != NULL)
DetectAddressFree(target);
return 0; return 0;
} }

@ -296,6 +296,9 @@ static void SCSigOrderByAction(DetectEngineCtx *de_ctx,
SCSigSignatureWrapper *max = NULL; SCSigSignatureWrapper *max = NULL;
SCSigSignatureWrapper *prev = NULL; SCSigSignatureWrapper *prev = NULL;
if (sw == NULL)
return;
if (de_ctx->sc_sig_sig_wrapper == NULL) { if (de_ctx->sc_sig_sig_wrapper == NULL) {
de_ctx->sc_sig_sig_wrapper = sw; de_ctx->sc_sig_sig_wrapper = sw;
sw->min = NULL; 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 */ /* set the min signature for this keyword, for the next ordering function */
if (sw == NULL)
return;
min = sw; min = sw;
while (min != NULL && min != sw->min) { while (min != NULL && min != sw->min) {
if (min->sig->action != sw->sig->action) if (min->sig->action != sw->sig->action)
@ -376,8 +377,6 @@ static void SCSigOrderByAction(DetectEngineCtx *de_ctx,
sw->min = min; sw->min = min;
/* set the max signature for this keyword + 1, for the next ordering func */ /* set the max signature for this keyword + 1, for the next ordering func */
if (sw == NULL)
return;
max = sw; max = sw;
while (max != NULL && max != sw->max) { while (max != NULL && max != sw->max) {
if (max->sig->action != sw->sig->action) if (max->sig->action != sw->sig->action)
@ -404,6 +403,9 @@ static void SCSigOrderByFlowbits(DetectEngineCtx *de_ctx,
SCSigSignatureWrapper *max = NULL; SCSigSignatureWrapper *max = NULL;
SCSigSignatureWrapper *prev = NULL; SCSigSignatureWrapper *prev = NULL;
if (sw == NULL)
return;
if (de_ctx->sc_sig_sig_wrapper == NULL) { if (de_ctx->sc_sig_sig_wrapper == NULL) {
de_ctx->sc_sig_sig_wrapper = sw; de_ctx->sc_sig_sig_wrapper = sw;
sw->min = NULL; 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 */ /* set the min signature for this keyword, for the next ordering function */
if (sw == NULL)
return;
min = sw; min = sw;
while (min != NULL && min != sw->min) { while (min != NULL && min != sw->min) {
if ( *((int *)(sw->user[SC_RADIX_USER_DATA_FLOWBITS])) != if ( *((int *)(sw->user[SC_RADIX_USER_DATA_FLOWBITS])) !=
@ -486,8 +486,6 @@ static void SCSigOrderByFlowbits(DetectEngineCtx *de_ctx,
sw->min = min; sw->min = min;
/* set the max signature for this keyword + 1, for the next ordering func */ /* set the max signature for this keyword + 1, for the next ordering func */
if (sw == NULL)
return;
max = sw; max = sw;
while (max!= NULL && max != sw->max) { while (max!= NULL && max != sw->max) {
if ( *((int *)(sw->user[SC_RADIX_USER_DATA_FLOWBITS])) != if ( *((int *)(sw->user[SC_RADIX_USER_DATA_FLOWBITS])) !=
@ -516,6 +514,9 @@ static void SCSigOrderByFlowvar(DetectEngineCtx *de_ctx,
SCSigSignatureWrapper *max = NULL; SCSigSignatureWrapper *max = NULL;
SCSigSignatureWrapper *prev = NULL; SCSigSignatureWrapper *prev = NULL;
if (sw == NULL)
return;
if (de_ctx->sc_sig_sig_wrapper == NULL) { if (de_ctx->sc_sig_sig_wrapper == NULL) {
de_ctx->sc_sig_sig_wrapper = sw; de_ctx->sc_sig_sig_wrapper = sw;
sw->min = NULL; 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 */ /* set the min signature for this keyword, for the next ordering function */
if (sw == NULL)
return;
min = sw; min = sw;
while (min != NULL && min != sw->min) { while (min != NULL && min != sw->min) {
if ( *((int *)(sw->user[SC_RADIX_USER_DATA_FLOWVAR])) != if ( *((int *)(sw->user[SC_RADIX_USER_DATA_FLOWVAR])) !=
@ -598,8 +597,6 @@ static void SCSigOrderByFlowvar(DetectEngineCtx *de_ctx,
sw->min = min; sw->min = min;
/* set the max signature for this keyword + 1, for the next ordering func */ /* set the max signature for this keyword + 1, for the next ordering func */
if (sw == NULL)
return;
max = sw; max = sw;
while (max != NULL && max != sw->max) { while (max != NULL && max != sw->max) {
if ( *((int *)(sw->user[SC_RADIX_USER_DATA_FLOWVAR])) != if ( *((int *)(sw->user[SC_RADIX_USER_DATA_FLOWVAR])) !=
@ -627,6 +624,9 @@ static void SCSigOrderByPktvar(DetectEngineCtx *de_ctx,
SCSigSignatureWrapper *max = NULL; SCSigSignatureWrapper *max = NULL;
SCSigSignatureWrapper *prev = NULL; SCSigSignatureWrapper *prev = NULL;
if (sw == NULL)
return;
if (de_ctx->sc_sig_sig_wrapper == NULL) { if (de_ctx->sc_sig_sig_wrapper == NULL) {
de_ctx->sc_sig_sig_wrapper = sw; de_ctx->sc_sig_sig_wrapper = sw;
sw->min = NULL; 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 */ /* set the min signature for this keyword, for the next ordering function */
if (sw == NULL)
return;
min = sw; min = sw;
while (min != NULL && min != sw->min) { while (min != NULL && min != sw->min) {
if ( *((int *)(sw->user[SC_RADIX_USER_DATA_PKTVAR])) != if ( *((int *)(sw->user[SC_RADIX_USER_DATA_PKTVAR])) !=
@ -709,8 +706,6 @@ static void SCSigOrderByPktvar(DetectEngineCtx *de_ctx,
sw->min = min; sw->min = min;
/* set the max signature for this keyword + 1, for the next ordering func */ /* set the max signature for this keyword + 1, for the next ordering func */
if (sw == NULL)
return;
max = sw; max = sw;
while (max != NULL && max != sw->max) { while (max != NULL && max != sw->max) {
if ( *((int *)(sw->user[SC_RADIX_USER_DATA_PKTVAR])) != if ( *((int *)(sw->user[SC_RADIX_USER_DATA_PKTVAR])) !=
@ -738,6 +733,9 @@ static void SCSigOrderByPriority(DetectEngineCtx *de_ctx,
SCSigSignatureWrapper *max = NULL; SCSigSignatureWrapper *max = NULL;
SCSigSignatureWrapper *prev = NULL; SCSigSignatureWrapper *prev = NULL;
if (sw == NULL)
return;
if (de_ctx->sc_sig_sig_wrapper == NULL) { if (de_ctx->sc_sig_sig_wrapper == NULL) {
de_ctx->sc_sig_sig_wrapper = sw; de_ctx->sc_sig_sig_wrapper = sw;
sw->min = NULL; 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 */ /* set the min signature for this keyword, for the next ordering function */
if (sw == NULL)
return;
min = sw; min = sw;
while (min != NULL && min != sw->min) { while (min != NULL && min != sw->min) {
if (min->sig->prio != sw->sig->prio) if (min->sig->prio != sw->sig->prio)
@ -819,9 +814,6 @@ static void SCSigOrderByPriority(DetectEngineCtx *de_ctx,
sw->min = min; sw->min = min;
/* set the max signature for this keyword + 1, for the next ordering func */ /* set the max signature for this keyword + 1, for the next ordering func */
if (sw == NULL)
return;
max = sw; max = sw;
while (max != NULL && max != sw->max) { while (max != NULL && max != sw->max) {
if (max->sig->prio != sw->sig->prio) if (max->sig->prio != sw->sig->prio)

@ -1151,7 +1151,7 @@ int DetectFastPatternTest17(void)
result = 0; result = 0;
sm = de_ctx->sig_list->sm_lists[DETECT_SM_LIST_PMATCH]; sm = de_ctx->sig_list->sm_lists[DETECT_SM_LIST_PMATCH];
DetectContentData *cd = sm->ctx; DetectContentData *cd = sm->ctx;
if (sm != NULL && sm->type == DETECT_CONTENT) { if (sm->type == DETECT_CONTENT) {
if (cd->flags & DETECT_CONTENT_FAST_PATTERN && if (cd->flags & DETECT_CONTENT_FAST_PATTERN &&
cd->flags & DETECT_CONTENT_FAST_PATTERN_ONLY && cd->flags & DETECT_CONTENT_FAST_PATTERN_ONLY &&
!(cd->flags & cd->flags & DETECT_CONTENT_FAST_PATTERN_CHOP) && !(cd->flags & cd->flags & DETECT_CONTENT_FAST_PATTERN_CHOP) &&
@ -1187,7 +1187,7 @@ int DetectFastPatternTest18(void)
result = 0; result = 0;
sm = de_ctx->sig_list->sm_lists[DETECT_SM_LIST_PMATCH]; sm = de_ctx->sig_list->sm_lists[DETECT_SM_LIST_PMATCH];
DetectContentData *cd = sm->ctx; DetectContentData *cd = sm->ctx;
if (sm != NULL && sm->type == DETECT_CONTENT) { if (sm->type == DETECT_CONTENT) {
if (cd->flags & DETECT_CONTENT_FAST_PATTERN && if (cd->flags & DETECT_CONTENT_FAST_PATTERN &&
!(cd->flags & DETECT_CONTENT_FAST_PATTERN_ONLY) && !(cd->flags & DETECT_CONTENT_FAST_PATTERN_ONLY) &&
cd->flags & cd->flags & DETECT_CONTENT_FAST_PATTERN_CHOP && cd->flags & cd->flags & DETECT_CONTENT_FAST_PATTERN_CHOP &&
@ -2198,7 +2198,7 @@ int DetectFastPatternTest56(void)
result = 0; result = 0;
sm = de_ctx->sig_list->sm_lists[DETECT_SM_LIST_UMATCH]; sm = de_ctx->sig_list->sm_lists[DETECT_SM_LIST_UMATCH];
DetectContentData *ud = sm->ctx; DetectContentData *ud = sm->ctx;
if (sm != NULL && sm->type == DETECT_URICONTENT) { if (sm->type == DETECT_URICONTENT) {
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_ONLY &&
!(ud->flags & DETECT_CONTENT_FAST_PATTERN_CHOP) && !(ud->flags & DETECT_CONTENT_FAST_PATTERN_CHOP) &&
@ -2234,7 +2234,7 @@ int DetectFastPatternTest57(void)
result = 0; result = 0;
sm = de_ctx->sig_list->sm_lists[DETECT_SM_LIST_UMATCH]; sm = de_ctx->sig_list->sm_lists[DETECT_SM_LIST_UMATCH];
DetectContentData *ud = sm->ctx; DetectContentData *ud = sm->ctx;
if (sm != NULL && sm->type == DETECT_URICONTENT) { if (sm->type == DETECT_URICONTENT) {
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_ONLY) &&
ud->flags & DETECT_CONTENT_FAST_PATTERN_CHOP && ud->flags & DETECT_CONTENT_FAST_PATTERN_CHOP &&
@ -3279,7 +3279,7 @@ int DetectFastPatternTest96(void)
result = 0; result = 0;
sm = de_ctx->sig_list->sm_lists[DETECT_SM_LIST_UMATCH]; sm = de_ctx->sig_list->sm_lists[DETECT_SM_LIST_UMATCH];
DetectContentData *ud = sm->ctx; DetectContentData *ud = sm->ctx;
if (sm != NULL && sm->type == DETECT_URICONTENT) { if (sm->type == DETECT_URICONTENT) {
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_ONLY &&
!(ud->flags & DETECT_CONTENT_FAST_PATTERN_CHOP) && !(ud->flags & DETECT_CONTENT_FAST_PATTERN_CHOP) &&
@ -3315,7 +3315,7 @@ int DetectFastPatternTest97(void)
result = 0; result = 0;
sm = de_ctx->sig_list->sm_lists[DETECT_SM_LIST_UMATCH]; sm = de_ctx->sig_list->sm_lists[DETECT_SM_LIST_UMATCH];
DetectContentData *ud = sm->ctx; DetectContentData *ud = sm->ctx;
if (sm != NULL && sm->type == DETECT_URICONTENT) { if (sm->type == DETECT_URICONTENT) {
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_ONLY) &&
ud->flags & DETECT_CONTENT_FAST_PATTERN_CHOP && ud->flags & DETECT_CONTENT_FAST_PATTERN_CHOP &&
@ -4382,16 +4382,14 @@ int DetectFastPatternTest137(void)
result = 0; result = 0;
sm = de_ctx->sig_list->sm_lists[DETECT_SM_LIST_HCBDMATCH]; sm = de_ctx->sig_list->sm_lists[DETECT_SM_LIST_HCBDMATCH];
DetectContentData *ud = sm->ctx; 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_ONLY &&
!(ud->flags & DETECT_CONTENT_FAST_PATTERN_CHOP) && !(ud->flags & DETECT_CONTENT_FAST_PATTERN_CHOP) &&
ud->fp_chop_offset == 0 && ud->fp_chop_offset == 0 &&
ud->fp_chop_len == 0) { ud->fp_chop_len == 0) {
result = 1; result = 1;
} else { } else {
result = 0; result = 0;
}
} }
end: end:
@ -4418,16 +4416,14 @@ int DetectFastPatternTest138(void)
result = 0; result = 0;
sm = de_ctx->sig_list->sm_lists[DETECT_SM_LIST_HCBDMATCH]; sm = de_ctx->sig_list->sm_lists[DETECT_SM_LIST_HCBDMATCH];
DetectContentData *ud = sm->ctx; 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_ONLY) &&
ud->flags & DETECT_CONTENT_FAST_PATTERN_CHOP && ud->flags & DETECT_CONTENT_FAST_PATTERN_CHOP &&
ud->fp_chop_offset == 3 && ud->fp_chop_offset == 3 &&
ud->fp_chop_len == 4) { ud->fp_chop_len == 4) {
result = 1; result = 1;
} else { } else {
result = 0; result = 0;
}
} }
end: end:
@ -5577,16 +5573,14 @@ int DetectFastPatternTest182(void)
result = 0; result = 0;
sm = de_ctx->sig_list->sm_lists[DETECT_SM_LIST_HHDMATCH]; sm = de_ctx->sig_list->sm_lists[DETECT_SM_LIST_HHDMATCH];
DetectContentData *ud = sm->ctx; 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_ONLY &&
!(ud->flags & DETECT_CONTENT_FAST_PATTERN_CHOP) && !(ud->flags & DETECT_CONTENT_FAST_PATTERN_CHOP) &&
ud->fp_chop_offset == 0 && ud->fp_chop_offset == 0 &&
ud->fp_chop_len == 0) { ud->fp_chop_len == 0) {
result = 1; result = 1;
} else { } else {
result = 0; result = 0;
}
} }
end: end:
@ -5613,16 +5607,14 @@ int DetectFastPatternTest183(void)
result = 0; result = 0;
sm = de_ctx->sig_list->sm_lists[DETECT_SM_LIST_HHDMATCH]; sm = de_ctx->sig_list->sm_lists[DETECT_SM_LIST_HHDMATCH];
DetectContentData *ud = sm->ctx; 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_ONLY) &&
ud->flags & DETECT_CONTENT_FAST_PATTERN_CHOP && ud->flags & DETECT_CONTENT_FAST_PATTERN_CHOP &&
ud->fp_chop_offset == 3 && ud->fp_chop_offset == 3 &&
ud->fp_chop_len == 4) { ud->fp_chop_len == 4) {
result = 1; result = 1;
} else { } else {
result = 0; result = 0;
}
} }
end: end:
@ -6696,16 +6688,14 @@ int DetectFastPatternTest223(void)
result = 0; result = 0;
sm = de_ctx->sig_list->sm_lists[DETECT_SM_LIST_HRHDMATCH]; sm = de_ctx->sig_list->sm_lists[DETECT_SM_LIST_HRHDMATCH];
DetectContentData *ud = sm->ctx; 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_ONLY &&
!(ud->flags & DETECT_CONTENT_FAST_PATTERN_CHOP) && !(ud->flags & DETECT_CONTENT_FAST_PATTERN_CHOP) &&
ud->fp_chop_offset == 0 && ud->fp_chop_offset == 0 &&
ud->fp_chop_len == 0) { ud->fp_chop_len == 0) {
result = 1; result = 1;
} else { } else {
result = 0; result = 0;
}
} }
end: end:
@ -6732,16 +6722,14 @@ int DetectFastPatternTest224(void)
result = 0; result = 0;
sm = de_ctx->sig_list->sm_lists[DETECT_SM_LIST_HRHDMATCH]; sm = de_ctx->sig_list->sm_lists[DETECT_SM_LIST_HRHDMATCH];
DetectContentData *ud = sm->ctx; 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_ONLY) &&
ud->flags & DETECT_CONTENT_FAST_PATTERN_CHOP && ud->flags & DETECT_CONTENT_FAST_PATTERN_CHOP &&
ud->fp_chop_offset == 3 && ud->fp_chop_offset == 3 &&
ud->fp_chop_len == 4) { ud->fp_chop_len == 4) {
result = 1; result = 1;
} else { } else {
result = 0; result = 0;
}
} }
end: end:
@ -7819,16 +7807,14 @@ int DetectFastPatternTest264(void)
result = 0; result = 0;
sm = de_ctx->sig_list->sm_lists[DETECT_SM_LIST_HMDMATCH]; sm = de_ctx->sig_list->sm_lists[DETECT_SM_LIST_HMDMATCH];
DetectContentData *ud = sm->ctx; 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_ONLY &&
!(ud->flags & DETECT_CONTENT_FAST_PATTERN_CHOP) && !(ud->flags & DETECT_CONTENT_FAST_PATTERN_CHOP) &&
ud->fp_chop_offset == 0 && ud->fp_chop_offset == 0 &&
ud->fp_chop_len == 0) { ud->fp_chop_len == 0) {
result = 1; result = 1;
} else { } else {
result = 0; result = 0;
}
} }
end: end:
@ -7855,16 +7841,14 @@ int DetectFastPatternTest265(void)
result = 0; result = 0;
sm = de_ctx->sig_list->sm_lists[DETECT_SM_LIST_HMDMATCH]; sm = de_ctx->sig_list->sm_lists[DETECT_SM_LIST_HMDMATCH];
DetectContentData *ud = sm->ctx; 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_ONLY) &&
ud->flags & DETECT_CONTENT_FAST_PATTERN_CHOP && ud->flags & DETECT_CONTENT_FAST_PATTERN_CHOP &&
ud->fp_chop_offset == 3 && ud->fp_chop_offset == 3 &&
ud->fp_chop_len == 4) { ud->fp_chop_len == 4) {
result = 1; result = 1;
} else { } else {
result = 0; result = 0;
}
} }
end: end:
@ -8937,16 +8921,14 @@ int DetectFastPatternTest305(void)
result = 0; result = 0;
sm = de_ctx->sig_list->sm_lists[DETECT_SM_LIST_HCDMATCH]; sm = de_ctx->sig_list->sm_lists[DETECT_SM_LIST_HCDMATCH];
DetectContentData *ud = sm->ctx; 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_ONLY &&
!(ud->flags & DETECT_CONTENT_FAST_PATTERN_CHOP) && !(ud->flags & DETECT_CONTENT_FAST_PATTERN_CHOP) &&
ud->fp_chop_offset == 0 && ud->fp_chop_offset == 0 &&
ud->fp_chop_len == 0) { ud->fp_chop_len == 0) {
result = 1; result = 1;
} else { } else {
result = 0; result = 0;
}
} }
end: end:
@ -8973,16 +8955,14 @@ int DetectFastPatternTest306(void)
result = 0; result = 0;
sm = de_ctx->sig_list->sm_lists[DETECT_SM_LIST_HCDMATCH]; sm = de_ctx->sig_list->sm_lists[DETECT_SM_LIST_HCDMATCH];
DetectContentData *ud = sm->ctx; 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_ONLY) &&
ud->flags & DETECT_CONTENT_FAST_PATTERN_CHOP && ud->flags & DETECT_CONTENT_FAST_PATTERN_CHOP &&
ud->fp_chop_offset == 3 && ud->fp_chop_offset == 3 &&
ud->fp_chop_len == 4) { ud->fp_chop_len == 4) {
result = 1; result = 1;
} else { } else {
result = 0; result = 0;
}
} }
end: end:
@ -10062,16 +10042,14 @@ int DetectFastPatternTest346(void)
result = 0; result = 0;
sm = de_ctx->sig_list->sm_lists[DETECT_SM_LIST_HRUDMATCH]; sm = de_ctx->sig_list->sm_lists[DETECT_SM_LIST_HRUDMATCH];
DetectContentData *ud = sm->ctx; 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_ONLY &&
!(ud->flags & DETECT_CONTENT_FAST_PATTERN_CHOP) && !(ud->flags & DETECT_CONTENT_FAST_PATTERN_CHOP) &&
ud->fp_chop_offset == 0 && ud->fp_chop_offset == 0 &&
ud->fp_chop_len == 0) { ud->fp_chop_len == 0) {
result = 1; result = 1;
} else { } else {
result = 0; result = 0;
}
} }
end: end:
@ -10098,16 +10076,14 @@ int DetectFastPatternTest347(void)
result = 0; result = 0;
sm = de_ctx->sig_list->sm_lists[DETECT_SM_LIST_HRUDMATCH]; sm = de_ctx->sig_list->sm_lists[DETECT_SM_LIST_HRUDMATCH];
DetectContentData *ud = sm->ctx; 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_ONLY) &&
ud->flags & DETECT_CONTENT_FAST_PATTERN_CHOP && ud->flags & DETECT_CONTENT_FAST_PATTERN_CHOP &&
ud->fp_chop_offset == 3 && ud->fp_chop_offset == 3 &&
ud->fp_chop_len == 4) { ud->fp_chop_len == 4) {
result = 1; result = 1;
} else { } else {
result = 0; result = 0;
}
} }
end: end:

@ -268,27 +268,29 @@ static int DetectIPProtoSetup(DetectEngineCtx *de_ctx, Signature *s, char *optst
} }
temp_sm = temp_sm->next; temp_sm = temp_sm->next;
} }
DetectIPProtoData *data_temp = temp_sm->ctx; if (temp_sm != NULL) {
if (data_temp->proto <= data->proto) { DetectIPProtoData *data_temp = temp_sm->ctx;
SCLogError(SC_ERR_INVALID_SIGNATURE, "We can't use a have " if (data_temp->proto <= data->proto) {
"both gt and lt ipprotos, with the lt being " SCLogError(SC_ERR_INVALID_SIGNATURE, "We can't use a have "
"lower than gt value"); "both gt and lt ipprotos, with the lt being "
goto error; "lower than gt value");
/* Updated by AS. Please do not remove this unused code. Need it goto error;
* as we redo this code once we solve ipproto multiple uses */ /* 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 #if 0
s->proto.proto[data->proto / 8] |= 0xfe << (data->proto % 8); s->proto.proto[data->proto / 8] |= 0xfe << (data->proto % 8);
for (i = (data->proto / 8) + 1; i < (256 / 8); i++) { for (i = (data->proto / 8) + 1; i < (256 / 8); i++) {
s->proto.proto[i] = 0xff; s->proto.proto[i] = 0xff;
} }
#endif #endif
} else { } else {
for (i = 0; i < (data->proto / 8); i++) { for (i = 0; i < (data->proto / 8); i++) {
s->proto.proto[i] = 0; s->proto.proto[i] = 0;
} }
s->proto.proto[data->proto / 8] &= 0xfe << (data->proto % 8); s->proto.proto[data->proto / 8] &= 0xfe << (data->proto % 8);
for (i = (data->proto / 8) + 1; i < (256 / 8); i++) { for (i = (data->proto / 8) + 1; i < (256 / 8); i++) {
s->proto.proto[i] &= 0xff; s->proto.proto[i] &= 0xff;
}
} }
} }
} else if (!lt_set && not_set) { } 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; temp_sm = temp_sm->next;
} }
data_temp = temp_sm->ctx; if (temp_sm != NULL) {
if (data_temp->proto <= data->proto) { data_temp = temp_sm->ctx;
/* Updated by AS. Please do not remove this unused code. if (data_temp->proto <= data->proto) {
* Need it as we redo this code once we solve ipproto /* Updated by AS. Please do not remove this unused code.
* multiple uses */ * Need it as we redo this code once we solve ipproto
SCLogError(SC_ERR_INVALID_SIGNATURE, "We can't use a have " * multiple uses */
"both gt and lt ipprotos, with the lt being " SCLogError(SC_ERR_INVALID_SIGNATURE, "We can't use a have "
"lower than gt value"); "both gt and lt ipprotos, with the lt being "
goto error; "lower than gt value");
goto error;
#if 0 #if 0
s->proto.proto[data->proto / 8] |= 0xfe << (data->proto % 8); s->proto.proto[data->proto / 8] |= 0xfe << (data->proto % 8);
for (i = (data->proto / 8) + 1; i < (256 / 8); i++) { for (i = (data->proto / 8) + 1; i < (256 / 8); i++) {
s->proto.proto[i] = 0xff; 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++;
} }
temp_sm = temp_sm->next; temp_sm = s->sm_lists[DETECT_SM_LIST_MATCH];
} uint8_t *not_protos = NULL;
qsort(not_protos, not_protos_len, sizeof(uint8_t), int not_protos_len = 0;
DetectIPProtoQSortCompare); while (temp_sm != NULL) {
int j = 0; if (temp_sm->type == DETECT_IPPROTO &&
while (j < not_protos_len) { ((DetectIPProtoData *)temp_sm->ctx)->op == DETECT_IPPROTO_OP_NOT) {
if (not_protos[j] < data->proto) { DetectIPProtoData *data_temp = temp_sm->ctx;
; not_protos = SCRealloc(not_protos,
} else { (not_protos_len + 1) * sizeof(uint8_t));
s->proto.proto[not_protos[j] / 8] &= ~(1 << (not_protos[j] % 8)); 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 #endif
}
} else { } else {
for (i = 0; i < (data->proto / 8); i++) { for (i = 0; i < (data->proto / 8); i++) {
s->proto.proto[i] = 0; s->proto.proto[i] = 0;
@ -383,28 +387,30 @@ static int DetectIPProtoSetup(DetectEngineCtx *de_ctx, Signature *s, char *optst
} }
temp_sm = temp_sm->next; temp_sm = temp_sm->next;
} }
DetectIPProtoData *data_temp = temp_sm->ctx; if (temp_sm != NULL) {
if (data_temp->proto >= data->proto) { DetectIPProtoData *data_temp = temp_sm->ctx;
/* Updated by AS. Please do not remove this unused code. if (data_temp->proto >= data->proto) {
* Need it as we redo this code once we solve ipproto /* Updated by AS. Please do not remove this unused code.
* multiple uses */ * Need it as we redo this code once we solve ipproto
SCLogError(SC_ERR_INVALID_SIGNATURE, "We can't use a have " * multiple uses */
"both gt and lt ipprotos, with the lt being " SCLogError(SC_ERR_INVALID_SIGNATURE, "We can't use a have "
"lower than gt value"); "both gt and lt ipprotos, with the lt being "
goto error; "lower than gt value");
goto error;
#if 0 #if 0
for (i = 0; i < (data->proto / 8); i++) { for (i = 0; i < (data->proto / 8); i++) {
s->proto.proto[i] = 0xff; s->proto.proto[i] = 0xff;
} }
s->proto.proto[data->proto / 8] |= ~(0xff << (data->proto % 8));; s->proto.proto[data->proto / 8] |= ~(0xff << (data->proto % 8));;
#endif #endif
} else { } else {
for (i = 0; i < (data->proto / 8); i++) { for (i = 0; i < (data->proto / 8); i++) {
s->proto.proto[i] &= 0xff; s->proto.proto[i] &= 0xff;
} }
s->proto.proto[data->proto / 8] &= ~(0xff << (data->proto % 8)); s->proto.proto[data->proto / 8] &= ~(0xff << (data->proto % 8));
for (i = (data->proto / 8) + 1; i < 256 / 8; i++) { for (i = (data->proto / 8) + 1; i < 256 / 8; i++) {
s->proto.proto[i] = 0; s->proto.proto[i] = 0;
}
} }
} }
} else if (!gt_set && not_set) { } 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; temp_sm = temp_sm->next;
} }
data_temp = temp_sm->ctx; if (temp_sm != NULL) {
if (data_temp->proto >= data->proto) { data_temp = temp_sm->ctx;
/* Updated by AS. Please do not remove this unused code. if (data_temp->proto >= data->proto) {
* Need it as we redo this code once we solve ipproto /* Updated by AS. Please do not remove this unused code.
* multiple uses */ * Need it as we redo this code once we solve ipproto
SCLogError(SC_ERR_INVALID_SIGNATURE, "We can't use a have " * multiple uses */
"both gt and lt ipprotos, with the lt being " SCLogError(SC_ERR_INVALID_SIGNATURE, "We can't use a have "
"lower than gt value"); "both gt and lt ipprotos, with the lt being "
goto error; "lower than gt value");
goto error;
#if 0 #if 0
for (i = 0; i < (data->proto / 8); i++) { for (i = 0; i < (data->proto / 8); i++) {
s->proto.proto[i] = 0xff; 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++;
} }
temp_sm = temp_sm->next; s->proto.proto[data->proto / 8] |= ~(0xff << (data->proto % 8));
} temp_sm = s->sm_lists[DETECT_SM_LIST_MATCH];
qsort(not_protos, not_protos_len, sizeof(uint8_t), uint8_t *not_protos = NULL;
DetectIPProtoQSortCompare); int not_protos_len = 0;
int j = 0; while (temp_sm != NULL) {
while (j < not_protos_len) { if (temp_sm->type == DETECT_IPPROTO &&
if (not_protos[j] < data->proto) { ((DetectIPProtoData *)temp_sm->ctx)->op == DETECT_IPPROTO_OP_NOT) {
s->proto.proto[not_protos[j] / 8] &= ~(1 << (not_protos[j] % 8)); DetectIPProtoData *data_temp = temp_sm->ctx;
} else { 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 #endif
}
} else { } else {
for (i = 0; i < (data->proto / 8); i++) { for (i = 0; i < (data->proto / 8); i++) {
s->proto.proto[i] &= 0xFF; s->proto.proto[i] &= 0xFF;

@ -215,7 +215,8 @@ void PoolPrintSaturation(Pool *p) {
*/ */
void *PoolTestAlloc(void *allocdata) { void *PoolTestAlloc(void *allocdata) {
return SCMalloc(10); void *ptr = SCMalloc(10);
return ptr;
} }
void *PoolTestAllocArg(void *allocdata) { void *PoolTestAllocArg(void *allocdata) {
size_t len = strlen((char *)allocdata) + 1; size_t len = strlen((char *)allocdata) + 1;

Loading…
Cancel
Save