Minor code cleanups fixing all GCC 4.6 compiler warnings for default, debug and unittests mode.

remotes/origin/master-1.1.x
Victor Julien 14 years ago
parent 2387c6b0e8
commit 2d16abcf8b

@ -1295,10 +1295,9 @@ int HTPParserTest01(void) {
htp_tx_t *tx = list_get(htp_state->connp->conn->transactions, 0);
bstr *key = NULL;
htp_header_t *h = NULL;
table_iterator_reset(tx->request_headers);
key = table_iterator_next(tx->request_headers, (void **) & h);
table_iterator_next(tx->request_headers, (void **) & h);
if (htp_state->connp == NULL || strcmp(bstr_tocstr(h->value), "Victor/1.0")
|| tx->request_method_number != M_POST ||
@ -1356,10 +1355,9 @@ int HTPParserTest02(void) {
htp_tx_t *tx = list_get(http_state->connp->conn->transactions, 0);
bstr *key = NULL;
htp_header_t *h = NULL;
table_iterator_reset(tx->request_headers);
key = table_iterator_next(tx->request_headers, (void **) & h);
table_iterator_next(tx->request_headers, (void **) & h);
if ((tx->request_method) != NULL || h != NULL)
{
@ -1421,10 +1419,9 @@ int HTPParserTest03(void) {
htp_tx_t *tx = list_get(htp_state->connp->conn->transactions, 0);
bstr *key = NULL;
htp_header_t *h = NULL;
table_iterator_reset(tx->request_headers);
key = table_iterator_next(tx->request_headers, (void **) & h);
table_iterator_next(tx->request_headers, (void **) & h);
if (htp_state->connp == NULL || tx->request_method_number != M_UNKNOWN ||
h != NULL || tx->request_protocol_number != HTTP_1_0)
@ -1465,6 +1462,9 @@ int HTPParserTest04(void) {
r = AppLayerParse(&f, ALPROTO_HTTP, STREAM_TOSERVER|STREAM_START|
STREAM_EOF, httpbuf1, httplen1);
if (r != 0) {
goto end;
}
htp_state = f.aldata[AlpGetStateIdx(ALPROTO_HTTP)];
if (htp_state == NULL) {
@ -1475,10 +1475,9 @@ int HTPParserTest04(void) {
htp_tx_t *tx = list_get(htp_state->connp->conn->transactions, 0);
bstr *key = NULL;
htp_header_t *h = NULL;
table_iterator_reset(tx->request_headers);
key = table_iterator_next(tx->request_headers, (void **) & h);
table_iterator_next(tx->request_headers, (void **) & h);
if (htp_state->connp == NULL || tx->request_method_number != M_UNKNOWN ||
h != NULL || tx->request_protocol_number != PROTOCOL_UNKNOWN)
@ -1583,10 +1582,9 @@ int HTPParserTest05(void) {
htp_tx_t *tx = list_get(http_state->connp->conn->transactions, 0);
bstr *key = NULL;
htp_header_t *h = NULL;
table_iterator_reset(tx->request_headers);
key = table_iterator_next(tx->request_headers, (void **) & h);
table_iterator_next(tx->request_headers, (void **) & h);
if (http_state->connp == NULL || tx->request_method_number != M_POST ||
h == NULL || tx->request_protocol_number != HTTP_1_0)
@ -1699,10 +1697,9 @@ int HTPParserTest06(void) {
htp_tx_t *tx = list_get(http_state->connp->conn->transactions, 0);
bstr *key = NULL;
htp_header_t *h = NULL;
table_iterator_reset(tx->request_headers);
key = table_iterator_next(tx->request_headers, (void **) & h);
table_iterator_next(tx->request_headers, (void **) & h);
if (http_state->connp == NULL || tx->request_method_number != M_GET ||
h == NULL || tx->request_protocol_number != HTTP_1_1)

@ -82,7 +82,7 @@ void DecodePPPOEDiscovery(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p, uint
/* parse any tags we have in the packet */
uint16_t tag_type = 0, tag_length = 0;
uint16_t tag_length = 0;
PPPOEDiscoveryTag* pppoedt = (PPPOEDiscoveryTag*) (p->pppoedh + PPPOE_DISCOVERY_HEADER_MIN_LEN);
uint16_t pppoe_length = ntohs(p->pppoedh->pppoe_length);
@ -99,7 +99,9 @@ void DecodePPPOEDiscovery(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p, uint
while (pppoedt < (PPPOEDiscoveryTag*) (pkt + (len - sizeof(PPPOEDiscoveryTag))) && pppoe_length >=4 && packet_length >=4)
{
tag_type = ntohs(pppoedt->pppoe_tag_type);
#ifdef DEBUG
uint16_t tag_type = ntohs(pppoedt->pppoe_tag_type);
#endif
tag_length = ntohs(pppoedt->pppoe_tag_length);
SCLogDebug ("PPPoE Tag type %x, length %u", tag_type, tag_length);

@ -3527,7 +3527,6 @@ int DetectByteExtractTest52(void)
SigMatch *sm = NULL;
DetectContentData *cd = NULL;
DetectByteExtractData *bed1 = NULL;
DetectByteExtractData *bed2 = NULL;
DetectBytetestData *btd = NULL;
de_ctx = DetectEngineCtxInit();
@ -3598,7 +3597,6 @@ int DetectByteExtractTest52(void)
result = 0;
goto end;
}
bed2 = (DetectByteExtractData *)sm->ctx;
sm = sm->next;
if (sm->type != DETECT_BYTETEST) {
@ -3766,7 +3764,6 @@ int DetectByteExtractTest54(void)
SigMatch *sm = NULL;
DetectContentData *cd = NULL;
DetectByteExtractData *bed1 = NULL;
DetectByteExtractData *bed2 = NULL;
DetectBytejumpData *bjd = NULL;
de_ctx = DetectEngineCtxInit();
@ -3837,7 +3834,6 @@ int DetectByteExtractTest54(void)
result = 0;
goto end;
}
bed2 = (DetectByteExtractData *)sm->ctx;
sm = sm->next;
if (sm->type != DETECT_BYTEJUMP) {
@ -4350,7 +4346,6 @@ int DetectByteExtractTest58(void)
SigMatch *sm = NULL;
DetectContentData *cd = NULL;
DetectByteExtractData *bed1 = NULL;
DetectByteExtractData *bed2 = NULL;
DetectBytejumpData *bjd = NULL;
DetectIsdataatData *isdd = NULL;
@ -4423,7 +4418,6 @@ int DetectByteExtractTest58(void)
result = 0;
goto end;
}
bed2 = (DetectByteExtractData *)sm->ctx;
sm = sm->next;
if (sm->type != DETECT_BYTEJUMP) {
@ -4485,7 +4479,6 @@ int DetectByteExtractTest59(void)
SigMatch *sm = NULL;
DetectContentData *cd = NULL;
DetectByteExtractData *bed1 = NULL;
DetectByteExtractData *bed2 = NULL;
DetectBytejumpData *bjd = NULL;
DetectIsdataatData *isdd = NULL;
@ -4558,7 +4551,6 @@ int DetectByteExtractTest59(void)
result = 0;
goto end;
}
bed2 = (DetectByteExtractData *)sm->ctx;
sm = sm->next;
if (sm->type != DETECT_BYTEJUMP) {

@ -81,9 +81,7 @@ static int DetectDistanceSetup (DetectEngineCtx *de_ctx, Signature *s,
SigMatch *dcem = NULL;
SigMatch *dm = NULL;
SigMatch *pm1 = NULL;
SigMatch *pm2 = NULL;
SigMatch *dm_ots = NULL;
SigMatch *pm1_ots = NULL;
SigMatch *pm2_ots = NULL;
@ -92,10 +90,6 @@ static int DetectDistanceSetup (DetectEngineCtx *de_ctx, Signature *s,
DETECT_DCE_OPNUM, s->sm_lists_tail[DETECT_SM_LIST_AMATCH],
DETECT_DCE_STUB_DATA, s->sm_lists_tail[DETECT_SM_LIST_AMATCH]);
dm_ots = SigMatchGetLastSMFromLists(s, 6,
DETECT_CONTENT, s->sm_lists_tail[DETECT_SM_LIST_DMATCH],
DETECT_PCRE, s->sm_lists_tail[DETECT_SM_LIST_DMATCH],
DETECT_BYTEJUMP, s->sm_lists_tail[DETECT_SM_LIST_DMATCH]);
pm1_ots = SigMatchGetLastSMFromLists(s, 6,
DETECT_CONTENT, s->sm_lists_tail[DETECT_SM_LIST_PMATCH],
DETECT_PCRE, s->sm_lists_tail[DETECT_SM_LIST_PMATCH],
@ -109,9 +103,6 @@ static int DetectDistanceSetup (DetectEngineCtx *de_ctx, Signature *s,
dm = SigMatchGetLastSMFromLists(s, 2, DETECT_CONTENT, s->sm_lists_tail[DETECT_SM_LIST_DMATCH]);
pm1 = SigMatchGetLastSMFromLists(s, 2, DETECT_CONTENT, s->sm_lists_tail[DETECT_SM_LIST_PMATCH]);
if (pm1 != NULL && pm1->prev != NULL) {
pm2 = SigMatchGetLastSMFromLists(s, 2, DETECT_CONTENT, pm1->prev);
}
if (dm == NULL && pm1 == NULL) {
SCLogError(SC_ERR_INVALID_SIGNATURE, "Invalid signature. within "

@ -400,7 +400,6 @@ int DetectEngineInspectHttpRawUri(DetectEngineCtx *de_ctx,
{
SCEnter();
SigMatch *sm = NULL;
int r = 0;
HtpState *htp_state = (HtpState *)alstate;
@ -417,9 +416,8 @@ int DetectEngineInspectHttpRawUri(DetectEngineCtx *de_ctx,
goto end;
}
sm = s->sm_lists[DETECT_SM_LIST_HRUDMATCH];
#ifdef DEBUG
SigMatch *sm = s->sm_lists[DETECT_SM_LIST_HRUDMATCH];
DetectContentData *co = (DetectContentData *)sm->ctx;
SCLogDebug("co->id %"PRIu32, co->id);
#endif

@ -434,7 +434,6 @@ int DetectEngineInspectPacketUris(DetectEngineCtx *de_ctx,
void *alstate)
{
SCEnter();
SigMatch *sm = NULL;
int r = 0;
HtpState *htp_state = NULL;
@ -452,9 +451,8 @@ int DetectEngineInspectPacketUris(DetectEngineCtx *de_ctx,
goto end;
}
sm = s->sm_lists[DETECT_SM_LIST_UMATCH];
#ifdef DEBUG
SigMatch *sm = s->sm_lists[DETECT_SM_LIST_UMATCH];
DetectContentData *co = (DetectContentData *)sm->ctx;
SCLogDebug("co->id %"PRIu32, co->id);
#endif

@ -1408,14 +1408,8 @@ int DetectFlowintTestPacket01Real()
SigGroupBuild(de_ctx);
DetectEngineThreadCtxInit(&th_v,(void *) de_ctx,(void *) &det_ctx);
/* Get the idx of the vars we are going to track */
uint16_t idx1, idx2;
idx1 = VariableNameGetIdx("myvar", DETECT_FLOWINT);
idx2 = VariableNameGetIdx("cntpackets", DETECT_FLOWINT);
int i;
/* Decode the packets, and test the matches*/
int i;
for (i = 0;i < 11;i++) {
memset(p, 0, SIZE_OF_PACKET);
p->pkt = (uint8_t *)(p + 1);
@ -1747,14 +1741,8 @@ int DetectFlowintTestPacket02Real()
de_ctx->sig_list->next->next->next->next->next = NULL;
SigGroupBuild(de_ctx);
//PatternMatchPrepare(mpm_ctx, MPM_B2G);
DetectEngineThreadCtxInit(&th_v,(void *) de_ctx,(void *) &det_ctx);
/* Get the idx of the vars we are going to track */
uint16_t idx1, idx2;
idx1 = VariableNameGetIdx("myvar", DETECT_FLOWINT);
idx2 = VariableNameGetIdx("cntpackets", DETECT_FLOWINT);
int i;
/* Decode the packets, and test the matches*/
@ -2085,14 +2073,8 @@ int DetectFlowintTestPacket03Real()
de_ctx->sig_list->next->next->next = NULL;
SigGroupBuild(de_ctx);
//PatternMatchPrepare(mpm_ctx, MPM_B2G);
DetectEngineThreadCtxInit(&th_v,(void *) de_ctx,(void *) &det_ctx);
/* Get the idx of the vars we are going to track */
uint16_t idx1, idx2;
idx1 = VariableNameGetIdx("myvar", DETECT_FLOWINT);
idx2 = VariableNameGetIdx("cntpackets", DETECT_FLOWINT);
int i;
/* Decode the packets, and test the matches*/

@ -510,7 +510,7 @@ uint32_t DetectUricontentInspectMpm(DetectEngineThreadCtx *det_ctx, Flow *f, Htp
/** \test Test case where path traversal has been sent as a path string in the
* HTTP URL and normalized path string is checked */
static int HTTPUriTest01(void) {
int result = 1;
int result = 0;
Flow f;
uint8_t httpbuf1[] = "GET /../../images.gif HTTP/1.1\r\nHost: www.ExA"
"mPlE.cOM\r\n\r\n";
@ -530,10 +530,14 @@ static int HTTPUriTest01(void) {
r = AppLayerParse(&f, ALPROTO_HTTP, STREAM_TOSERVER|STREAM_START|
STREAM_EOF, httpbuf1, httplen1);
if (r != 0) {
printf("AppLayerParse failed: r(%d) != 0: ", r);
goto end;
}
HtpState *htp_state = f.aldata[AlpGetStateIdx(ALPROTO_HTTP)];
if (htp_state == NULL) {
printf("no http state: ");
result = 0;
goto end;
}
@ -545,7 +549,6 @@ static int HTTPUriTest01(void) {
printf("expected method GET and got %s: , expected protocol "
"HTTP/1.1 and got %s \n", bstr_tocstr(tx->request_method),
bstr_tocstr(tx->request_protocol));
result = 0;
goto end;
}
@ -554,7 +557,6 @@ static int HTTPUriTest01(void) {
{
printf("expected www.example.com as hostname, but got: %s \n",
bstr_tocstr(tx->parsed_uri->hostname));
result = 0;
goto end;
}
@ -563,10 +565,10 @@ static int HTTPUriTest01(void) {
{
printf("expected /images.gif as path, but got: %s \n",
bstr_tocstr(tx->parsed_uri->path));
result = 0;
goto end;
}
result = 1;
end:
FlowL7DataPtrFree(&f);
StreamTcpFreeConfig(TRUE);
@ -577,7 +579,7 @@ end:
/** \test Test case where path traversal has been sent in special characters in
* HEX encoding in the HTTP URL and normalized path string is checked */
static int HTTPUriTest02(void) {
int result = 1;
int result = 0;
Flow f;
HtpState *htp_state = NULL;
uint8_t httpbuf1[] = "GET /%2e%2e/images.gif HTTP/1.1\r\nHost: www.ExA"
@ -598,11 +600,14 @@ static int HTTPUriTest02(void) {
r = AppLayerParse(&f, ALPROTO_HTTP, STREAM_TOSERVER|STREAM_START|
STREAM_EOF, httpbuf1, httplen1);
if (r != 0) {
printf("AppLayerParse failed: r(%d) != 0: ", r);
goto end;
}
htp_state = f.aldata[AlpGetStateIdx(ALPROTO_HTTP)];
if (htp_state == NULL) {
printf("no http state: ");
result = 0;
goto end;
}
@ -614,7 +619,6 @@ static int HTTPUriTest02(void) {
printf("expected method GET and got %s: , expected protocol "
"HTTP/1.1 and got %s \n", bstr_tocstr(tx->request_method),
bstr_tocstr(tx->request_protocol));
result = 0;
goto end;
}
@ -623,7 +627,6 @@ static int HTTPUriTest02(void) {
{
printf("expected www.example.com as hostname, but got: %s \n",
bstr_tocstr(tx->parsed_uri->hostname));
result = 0;
goto end;
}
@ -632,15 +635,15 @@ static int HTTPUriTest02(void) {
{
printf("expected /images.gif as path, but got: %s \n",
bstr_tocstr(tx->parsed_uri->path));
result = 0;
goto end;
}
result = 1;
end:
FlowL7DataPtrFree(&f);
StreamTcpFreeConfig(TRUE);
if (htp_state != NULL) HTPStateFree(htp_state);
if (htp_state != NULL)
HTPStateFree(htp_state);
FLOW_DESTROY(&f);
return result;
}
@ -648,8 +651,9 @@ end:
/** \test Test case where NULL character has been sent in HEX encoding in the
* HTTP URL and normalized path string is checked */
static int HTTPUriTest03(void) {
int result = 1;
int result = 0;
Flow f;
HtpState *htp_state = NULL;
uint8_t httpbuf1[] = "GET%00 /images.gif HTTP/1.1\r\nHost: www.ExA"
"mPlE.cOM\r\n\r\n";
uint32_t httplen1 = sizeof(httpbuf1) - 1; /* minus the \0 */
@ -668,11 +672,14 @@ static int HTTPUriTest03(void) {
r = AppLayerParse(&f, ALPROTO_HTTP, STREAM_TOSERVER|STREAM_START|
STREAM_EOF, httpbuf1, httplen1);
if (r != 0) {
printf("AppLayerParse failed: r(%d) != 0: ", r);
goto end;
}
HtpState *htp_state = f.aldata[AlpGetStateIdx(ALPROTO_HTTP)];
htp_state = f.aldata[AlpGetStateIdx(ALPROTO_HTTP)];
if (htp_state == NULL) {
printf("no http state: ");
result = 0;
goto end;
}
@ -684,7 +691,6 @@ static int HTTPUriTest03(void) {
printf("expected method GET and got %s: , expected protocol "
"HTTP/1.1 and got %s \n", bstr_tocstr(tx->request_method),
bstr_tocstr(tx->request_protocol));
result = 0;
goto end;
}
@ -693,7 +699,6 @@ static int HTTPUriTest03(void) {
{
printf("expected www.example.com as hostname, but got: %s \n",
bstr_tocstr(tx->parsed_uri->hostname));
result = 0;
goto end;
}
@ -702,14 +707,15 @@ static int HTTPUriTest03(void) {
{
printf("expected /images.gif as path, but got: %s \n",
bstr_tocstr(tx->parsed_uri->path));
result = 0;
goto end;
}
result = 1;
end:
FlowL7DataPtrFree(&f);
StreamTcpFreeConfig(TRUE);
if (htp_state != NULL) HTPStateFree(htp_state);
if (htp_state != NULL)
HTPStateFree(htp_state);
FLOW_DESTROY(&f);
return result;
}
@ -718,8 +724,9 @@ end:
/** \test Test case where self referencing directories request has been sent
* in the HTTP URL and normalized path string is checked */
static int HTTPUriTest04(void) {
int result = 1;
int result = 0;
Flow f;
HtpState *htp_state = NULL;
uint8_t httpbuf1[] = "GET /./././images.gif HTTP/1.1\r\nHost: www.ExA"
"mPlE.cOM\r\n\r\n";
uint32_t httplen1 = sizeof(httpbuf1) - 1; /* minus the \0 */
@ -738,8 +745,12 @@ static int HTTPUriTest04(void) {
r = AppLayerParse(&f, ALPROTO_HTTP, STREAM_TOSERVER|STREAM_START|
STREAM_EOF, httpbuf1, httplen1);
if (r != 0) {
printf("AppLayerParse failed: r(%d) != 0: ", r);
goto end;
}
HtpState *htp_state = f.aldata[AlpGetStateIdx(ALPROTO_HTTP)];
htp_state = f.aldata[AlpGetStateIdx(ALPROTO_HTTP)];
if (htp_state == NULL) {
printf("no http state: ");
result = 0;
@ -776,11 +787,12 @@ static int HTTPUriTest04(void) {
goto end;
}
result = 1;
end:
FlowL7DataPtrFree(&f);
StreamTcpFreeConfig(TRUE);
if (htp_state != NULL) HTPStateFree(htp_state);
if (htp_state != NULL)
HTPStateFree(htp_state);
FLOW_DESTROY(&f);
return result;
}

@ -84,9 +84,7 @@ static int DetectWithinSetup (DetectEngineCtx *de_ctx, Signature *s, char *withi
SigMatch *dcem = NULL;
SigMatch *dm = NULL;
SigMatch *pm1 = NULL;
SigMatch *pm2 = NULL;
SigMatch *dm_ots = NULL;
SigMatch *pm1_ots = NULL;
SigMatch *pm2_ots = NULL;
@ -95,10 +93,6 @@ static int DetectWithinSetup (DetectEngineCtx *de_ctx, Signature *s, char *withi
DETECT_DCE_OPNUM, s->sm_lists_tail[DETECT_SM_LIST_AMATCH],
DETECT_DCE_STUB_DATA, s->sm_lists_tail[DETECT_SM_LIST_AMATCH]);
dm_ots = SigMatchGetLastSMFromLists(s, 6,
DETECT_CONTENT, s->sm_lists_tail[DETECT_SM_LIST_DMATCH],
DETECT_PCRE, s->sm_lists_tail[DETECT_SM_LIST_DMATCH],
DETECT_BYTEJUMP, s->sm_lists_tail[DETECT_SM_LIST_DMATCH]);
pm1_ots = SigMatchGetLastSMFromLists(s, 6,
DETECT_CONTENT, s->sm_lists_tail[DETECT_SM_LIST_PMATCH],
DETECT_PCRE, s->sm_lists_tail[DETECT_SM_LIST_PMATCH],
@ -112,9 +106,6 @@ static int DetectWithinSetup (DetectEngineCtx *de_ctx, Signature *s, char *withi
dm = SigMatchGetLastSMFromLists(s, 2, DETECT_CONTENT, s->sm_lists_tail[DETECT_SM_LIST_DMATCH]);
pm1 = SigMatchGetLastSMFromLists(s, 2, DETECT_CONTENT, s->sm_lists_tail[DETECT_SM_LIST_PMATCH]);
if (pm1 != NULL && pm1->prev != NULL) {
pm2 = SigMatchGetLastSMFromLists(s, 2, DETECT_CONTENT, pm1->prev);
}
if (dm == NULL && pm1 == NULL) {
SCLogError(SC_ERR_INVALID_SIGNATURE, "Invalid signature. within "

@ -1168,8 +1168,6 @@ static inline void DetectMpmPrefilter(DetectEngineCtx *de_ctx,
DetectEngineThreadCtx *det_ctx, StreamMsg *smsg, Packet *p,
uint8_t flags, uint16_t alproto, void *alstate, uint8_t *sms_runflags)
{
uint32_t cnt = 0;
if (p->payload_len > 0 && (!(p->flags & PKT_NOPAYLOAD_INSPECTION))) {
if (det_ctx->sgh->flags & SIG_GROUP_HEAD_MPM_PACKET) {
/* run the multi packet matcher against the payload of the packet */
@ -1177,10 +1175,9 @@ static inline void DetectMpmPrefilter(DetectEngineCtx *de_ctx,
det_ctx->sgh, det_ctx->sgh->mpm_content_maxlen, det_ctx->sgh->sig_cnt);
PACKET_PROFILING_DETECT_START(p, PROF_DETECT_MPM_PACKET);
cnt = PacketPatternSearch(det_ctx, p);
PacketPatternSearch(det_ctx, p);
PACKET_PROFILING_DETECT_END(p, PROF_DETECT_MPM_PACKET);
SCLogDebug("post search: cnt %" PRIu32, cnt);
*sms_runflags |= SMS_USED_PM;
}
if (!(p->flags & PKT_STREAM_ADD) && det_ctx->sgh->flags & SIG_GROUP_HEAD_MPM_STREAM) {
@ -1196,10 +1193,9 @@ static inline void DetectMpmPrefilter(DetectEngineCtx *de_ctx,
SCLogDebug("p->flowflags & FLOW_PKT_ESTABLISHED");
if (smsg != NULL && det_ctx->sgh->flags & SIG_GROUP_HEAD_MPM_STREAM) {
PACKET_PROFILING_DETECT_START(p, PROF_DETECT_MPM_STREAM);
cnt = StreamPatternSearch(det_ctx, p, smsg, flags);
StreamPatternSearch(det_ctx, p, smsg, flags);
PACKET_PROFILING_DETECT_END(p, PROF_DETECT_MPM_STREAM);
SCLogDebug("Stream Mpm cnt %u", cnt);
*sms_runflags |= SMS_USED_STREAM_PM;
} else {
SCLogDebug("smsg NULL (%p) or det_ctx->sgh->mpm_stream_ctx "
@ -1210,45 +1206,38 @@ static inline void DetectMpmPrefilter(DetectEngineCtx *de_ctx,
if (alproto == ALPROTO_HTTP && alstate != NULL) {
if (det_ctx->sgh->flags & SIG_GROUP_HEAD_MPM_URI) {
PACKET_PROFILING_DETECT_START(p, PROF_DETECT_MPM_URI);
cnt = DetectUricontentInspectMpm(det_ctx, p->flow, alstate);
DetectUricontentInspectMpm(det_ctx, p->flow, alstate);
PACKET_PROFILING_DETECT_END(p, PROF_DETECT_MPM_URI);
SCLogDebug("uri search: cnt %" PRIu32, cnt);
}
if (det_ctx->sgh->flags & SIG_GROUP_HEAD_MPM_HCBD) {
PACKET_PROFILING_DETECT_START(p, PROF_DETECT_MPM_HCBD);
cnt = DetectEngineRunHttpClientBodyMpm(de_ctx, det_ctx, p->flow, alstate);
DetectEngineRunHttpClientBodyMpm(de_ctx, det_ctx, p->flow, alstate);
PACKET_PROFILING_DETECT_END(p, PROF_DETECT_MPM_HCBD);
SCLogDebug("hcbd search: cnt %" PRIu32, cnt);
}
if (det_ctx->sgh->flags & SIG_GROUP_HEAD_MPM_HHD) {
PACKET_PROFILING_DETECT_START(p, PROF_DETECT_MPM_HHD);
cnt = DetectEngineRunHttpHeaderMpm(det_ctx, p->flow, alstate);
DetectEngineRunHttpHeaderMpm(det_ctx, p->flow, alstate);
PACKET_PROFILING_DETECT_END(p, PROF_DETECT_MPM_HHD);
SCLogDebug("hhd search: cnt %" PRIu32, cnt);
}
if (det_ctx->sgh->flags & SIG_GROUP_HEAD_MPM_HRHD) {
PACKET_PROFILING_DETECT_START(p, PROF_DETECT_MPM_HRHD);
cnt = DetectEngineRunHttpRawHeaderMpm(det_ctx, p->flow, alstate);
DetectEngineRunHttpRawHeaderMpm(det_ctx, p->flow, alstate);
PACKET_PROFILING_DETECT_END(p, PROF_DETECT_MPM_HRHD);
SCLogDebug("hrhd search: cnt %" PRIu32, cnt);
}
if (det_ctx->sgh->flags & SIG_GROUP_HEAD_MPM_HMD) {
PACKET_PROFILING_DETECT_START(p, PROF_DETECT_MPM_HMD);
cnt = DetectEngineRunHttpMethodMpm(det_ctx, p->flow, alstate);
DetectEngineRunHttpMethodMpm(det_ctx, p->flow, alstate);
PACKET_PROFILING_DETECT_END(p, PROF_DETECT_MPM_HMD);
SCLogDebug("hmd search: cnt %" PRIu32, cnt);
}
if (det_ctx->sgh->flags & SIG_GROUP_HEAD_MPM_HCD) {
PACKET_PROFILING_DETECT_START(p, PROF_DETECT_MPM_HCD);
cnt = DetectEngineRunHttpCookieMpm(det_ctx, p->flow, alstate);
DetectEngineRunHttpCookieMpm(det_ctx, p->flow, alstate);
PACKET_PROFILING_DETECT_END(p, PROF_DETECT_MPM_HCD);
SCLogDebug("hcd search: cnt %" PRIu32, cnt);
}
if (det_ctx->sgh->flags & SIG_GROUP_HEAD_MPM_HRUD) {
PACKET_PROFILING_DETECT_START(p, PROF_DETECT_MPM_HRUD);
cnt = DetectEngineRunHttpRawUriMpm(det_ctx, p->flow, alstate);
DetectEngineRunHttpRawUriMpm(det_ctx, p->flow, alstate);
PACKET_PROFILING_DETECT_END(p, PROF_DETECT_MPM_HRUD);
SCLogDebug("hrud search: cnt %" PRIu32, cnt);
}
}
} else {

@ -99,7 +99,7 @@ void *ParsePcapConfig(const char *iface)
aconf->buffer_size = 0;
/* If set command line option has precedence over config */
if ((ConfGetInt("pcap.buffer-size", &value)) == 1) {
SCLogInfo("Pcap will use %d buffer size");
SCLogInfo("Pcap will use %d buffer size", (int)value);
aconf->buffer_size = value;
}
@ -130,7 +130,8 @@ void *ParsePcapConfig(const char *iface)
if (aconf->buffer_size == 0) {
if ((ConfGetChildValueInt(if_root, "buffer-size", &value)) == 1) {
aconf->buffer_size = value;
SCLogInfo("Pcap will use %d buffer size (config file provided value)");
SCLogInfo("Pcap will use %d buffer size (config file provided "
"value)", (int)value);
}
}

@ -5531,7 +5531,6 @@ static int StreamTcpReassembleTest31 (void) {
uint32_t seq;
uint32_t ack;
uint8_t th_flag;
uint8_t th_flags;
uint8_t flowflags;
uint8_t check_contents[5] = {0x41, 0x41, 0x42, 0x42, 0x42};
TcpReassemblyThreadCtx *ra_ctx = StreamTcpReassembleInitThreadCtx();
@ -5540,7 +5539,6 @@ static int StreamTcpReassembleTest31 (void) {
flowflags = FLOW_PKT_TOSERVER;
th_flag = TH_ACK|TH_PUSH;
th_flags = TH_ACK;
ssn.server.ra_raw_base_seq = 9;
ssn.server.isn = 9;

@ -825,7 +825,6 @@ int SCLogPrintFDFilters(void)
{
SCLogFDFilter *fdf = NULL;
int count = 0;
int r = 0;
if (sc_log_module_initialized != 1) {
printf("Logging module not initialized. Call SCLogInitLogModule() "
@ -837,7 +836,7 @@ int SCLogPrintFDFilters(void)
printf("FD filters:\n");
#endif
r = SCMutexLock(&sc_log_fd_filters_m);
SCMutexLock(&sc_log_fd_filters_m);
fdf = sc_log_fd_filters;
while (fdf != NULL) {
@ -848,7 +847,7 @@ int SCLogPrintFDFilters(void)
count++;
}
r = SCMutexUnlock(&sc_log_fd_filters_m);
SCMutexUnlock(&sc_log_fd_filters_m);
return count;
}

@ -4199,12 +4199,15 @@ this_end:
* \test SC_RADIX_NODE_USERDATA macro
*/
static int SCRadixTestUserdataMacro01(void) {
SCRadixNode node;
int result = 0;
SCRadixNode *node = SCMalloc(sizeof(SCRadixNode));
if (node == NULL) {
goto end;
}
memset(&node, 0x00, sizeof(node));
memset(node, 0x00, sizeof(node));
void *ptr = SC_RADIX_NODE_USERDATA(&node, void);
void *ptr = SC_RADIX_NODE_USERDATA(node, void);
if (ptr != NULL) {
printf("ptr %p, expected NULL: ", ptr);
goto end;
@ -4212,6 +4215,8 @@ static int SCRadixTestUserdataMacro01(void) {
result = 1;
end:
if (node != NULL)
SCFree(node);
return result;
}
@ -4219,16 +4224,19 @@ end:
* \test SC_RADIX_NODE_USERDATA macro
*/
static int SCRadixTestUserdataMacro02(void) {
SCRadixNode node;
SCRadixPrefix prefix;
int result = 0;
SCRadixNode *node = SCMalloc(sizeof(SCRadixNode));
if (node == NULL) {
goto end;
}
memset(&node, 0x00, sizeof(node));
memset(node, 0x00, sizeof(node));
memset(&prefix, 0x00, sizeof(prefix));
node.prefix = &prefix;
node->prefix = &prefix;
void *ptr = SC_RADIX_NODE_USERDATA(&node, void);
void *ptr = SC_RADIX_NODE_USERDATA(node, void);
if (ptr != NULL) {
printf("ptr %p, expected NULL: ", ptr);
goto end;
@ -4236,6 +4244,8 @@ static int SCRadixTestUserdataMacro02(void) {
result = 1;
end:
if (node != NULL)
SCFree(node);
return result;
}
@ -4243,18 +4253,21 @@ end:
* \test SC_RADIX_NODE_USERDATA macro
*/
static int SCRadixTestUserdataMacro03(void) {
SCRadixNode node;
SCRadixPrefix prefix;
int result = 0;
void *somep = &result;
SCRadixNode *node = SCMalloc(sizeof(SCRadixNode));
if (node == NULL) {
goto end;
}
memset(&node, 0x00, sizeof(node));
memset(node, 0x00, sizeof(node));
memset(&prefix, 0x00, sizeof(prefix));
node.prefix = &prefix;
node->prefix = &prefix;
prefix.user_data_result = somep;
void *ptr = SC_RADIX_NODE_USERDATA(&node, void);
void *ptr = SC_RADIX_NODE_USERDATA(node, void);
if (ptr != somep) {
printf("ptr %p, expected %p: ", ptr, somep);
goto end;
@ -4262,6 +4275,8 @@ static int SCRadixTestUserdataMacro03(void) {
result = 1;
end:
if (node != NULL)
SCFree(node);
return result;
}

@ -828,7 +828,6 @@ void SCThresholdConfParseFile(DetectEngineCtx *de_ctx, FILE *fd)
{
char *line = NULL;
int len = 0;
int c;
int rule_num = 0;
/* position of "\", on multiline rules */
@ -855,7 +854,7 @@ void SCThresholdConfParseFile(DetectEngineCtx *de_ctx, FILE *fd)
break;
/* Skip EOL to inspect the next line (or read EOF) */
c = fgetc(fd);
(void)fgetc(fd);
if (SCThresholdConfIsLineBlankOrComment(line)) {
continue;
@ -869,7 +868,7 @@ void SCThresholdConfParseFile(DetectEngineCtx *de_ctx, FILE *fd)
}
} else {
/* Skip EOL to inspect the next line (or read EOF) */
c = fgetc(fd);
(void)fgetc(fd);
if (feof(fd))
break;
}

Loading…
Cancel
Save