unittests: clean up memory for signature tests

pull/14025/head
Victor Julien 2 months ago committed by Victor Julien
parent d551881a7e
commit 5ab8b8cd49

@ -1583,11 +1583,8 @@ static int DetectContentParseTest20(void)
goto end;
}
end:
SigGroupCleanup(de_ctx);
SigCleanSignatures(de_ctx);
end:
DetectEngineCtxFree(de_ctx);
return result;
}
@ -1612,11 +1609,8 @@ static int DetectContentParseTest21(void)
goto end;
}
end:
SigGroupCleanup(de_ctx);
SigCleanSignatures(de_ctx);
end:
DetectEngineCtxFree(de_ctx);
return result;
}
@ -1641,11 +1635,8 @@ static int DetectContentParseTest22(void)
goto end;
}
end:
SigGroupCleanup(de_ctx);
SigCleanSignatures(de_ctx);
end:
DetectEngineCtxFree(de_ctx);
return result;
}
@ -1670,11 +1661,8 @@ static int DetectContentParseTest23(void)
goto end;
}
end:
SigGroupCleanup(de_ctx);
SigCleanSignatures(de_ctx);
end:
DetectEngineCtxFree(de_ctx);
return result;
}
@ -1713,10 +1701,7 @@ static int DetectContentParseTest24(void)
result = (strncmp("boo", (char *)cd->content, cd->content_len) == 0);
end:
SigGroupCleanup(de_ctx);
SigCleanSignatures(de_ctx);
DetectEngineCtxFree(de_ctx);
return result;
}
@ -1741,11 +1726,8 @@ static int DetectContentParseTest25(void)
goto end;
}
end:
SigGroupCleanup(de_ctx);
SigCleanSignatures(de_ctx);
end:
DetectEngineCtxFree(de_ctx);
return result;
}
@ -1770,11 +1752,8 @@ static int DetectContentParseTest26(void)
goto end;
}
end:
SigGroupCleanup(de_ctx);
SigCleanSignatures(de_ctx);
end:
DetectEngineCtxFree(de_ctx);
return result;
}
@ -1799,11 +1778,8 @@ static int DetectContentParseTest27(void)
goto end;
}
end:
SigGroupCleanup(de_ctx);
SigCleanSignatures(de_ctx);
end:
DetectEngineCtxFree(de_ctx);
return result;
}
@ -1828,11 +1804,8 @@ static int DetectContentParseTest28(void)
goto end;
}
end:
SigGroupCleanup(de_ctx);
SigCleanSignatures(de_ctx);
end:
DetectEngineCtxFree(de_ctx);
return result;
}
@ -1857,11 +1830,8 @@ static int DetectContentParseTest29(void)
goto end;
}
end:
SigGroupCleanup(de_ctx);
SigCleanSignatures(de_ctx);
end:
DetectEngineCtxFree(de_ctx);
return result;
}
@ -1886,11 +1856,8 @@ static int DetectContentParseTest30(void)
goto end;
}
end:
SigGroupCleanup(de_ctx);
SigCleanSignatures(de_ctx);
end:
DetectEngineCtxFree(de_ctx);
return result;
}
@ -1915,11 +1882,8 @@ static int DetectContentParseTest31(void)
goto end;
}
end:
SigGroupCleanup(de_ctx);
SigCleanSignatures(de_ctx);
end:
DetectEngineCtxFree(de_ctx);
return result;
}
@ -1944,11 +1908,8 @@ static int DetectContentParseTest32(void)
goto end;
}
end:
SigGroupCleanup(de_ctx);
SigCleanSignatures(de_ctx);
end:
DetectEngineCtxFree(de_ctx);
return result;
}
@ -1973,11 +1934,8 @@ static int DetectContentParseTest33(void)
goto end;
}
end:
SigGroupCleanup(de_ctx);
SigCleanSignatures(de_ctx);
end:
DetectEngineCtxFree(de_ctx);
return result;
}
@ -2002,11 +1960,8 @@ static int DetectContentParseTest34(void)
goto end;
}
end:
SigGroupCleanup(de_ctx);
SigCleanSignatures(de_ctx);
end:
DetectEngineCtxFree(de_ctx);
return result;
}
@ -2031,11 +1986,8 @@ static int DetectContentParseTest35(void)
goto end;
}
end:
SigGroupCleanup(de_ctx);
SigCleanSignatures(de_ctx);
end:
DetectEngineCtxFree(de_ctx);
return result;
}
@ -2064,10 +2016,10 @@ static int SigTestPositiveTestContent(const char *rule, uint8_t *buf)
FAIL_IF(PacketAlertCheck(p, 1) != 1);
UTHFreePackets(&p, 1);
DetectEngineThreadCtxDeinit(&th_v, (void *)det_ctx);
DetectEngineCtxFree(de_ctx);
UTHFreePackets(&p, 1);
StatsThreadCleanup(&th_v);
PASS;
}
@ -2258,15 +2210,14 @@ static int SigTestNegativeTestContent(const char *rule, uint8_t *buf)
result = 1;
end:
UTHFreePackets(&p, 1);
if (det_ctx != NULL) {
DetectEngineThreadCtxDeinit(&th_v, (void *)det_ctx);
}
if (de_ctx != NULL) {
SigGroupCleanup(de_ctx);
SigCleanSignatures(de_ctx);
DetectEngineCtxFree(de_ctx);
}
UTHFreePackets(&p, 1);
StatsThreadCleanup(&th_v);
return result;
}

@ -982,9 +982,11 @@ static int SigGroupHeadTest06(void)
const SigGroupHead *sgh = SigMatchSignaturesGetSgh(de_ctx, p);
FAIL_IF_NULL(sgh);
DetectEngineCtxFree(de_ctx);
UTHFreePackets(&p, 1);
DetectEngineThreadCtxDeinit(&th_v, (void *)det_ctx);
DetectEngineCtxFree(de_ctx);
StatsThreadCleanup(&th_v);
PASS;
}
#endif

@ -4626,9 +4626,9 @@ static int SigTestBidirec03 (void)
end:
if (p != NULL) {
PacketRecycle(p);
SCFree(p);
PacketFree(p);
}
DetectEngineCtxFree(de_ctx);
FlowShutdown();
return result;
}
@ -4771,13 +4771,12 @@ static int SigTestBidirec04 (void)
end:
if (de_ctx != NULL) {
SigCleanSignatures(de_ctx);
SigGroupCleanup(de_ctx);
DetectEngineCtxFree(de_ctx);
}
if (p != NULL)
SCFree(p);
PacketFree(p);
StatsThreadCleanup(&th_v);
return result;
}
@ -4955,7 +4954,8 @@ static int SigParseTestNegation08 (void)
goto end;
de_ctx->flags |= DE_QUIET;
s = SigInit(de_ctx,"alert tcp any any -> [192.168.0.0/16,!192.168.0.0/24] any (sid:410006; rev:1;)");
s = DetectEngineAppendSig(de_ctx,
"alert tcp any any -> [192.168.0.0/16,!192.168.0.0/24] any (sid:410006; rev:1;)");
if (s == NULL) {
goto end;
}
@ -5127,19 +5127,15 @@ end:
static int SigParseTestUnbalancedQuotes01(void)
{
DetectEngineCtx *de_ctx;
Signature *s;
de_ctx = DetectEngineCtxInit();
DetectEngineCtx *de_ctx = DetectEngineCtxInit();
FAIL_IF_NULL(de_ctx);
de_ctx->flags |= DE_QUIET;
s = SigInit(de_ctx,
Signature *s = DetectEngineAppendSig(de_ctx,
"alert http any any -> any any (msg:\"SigParseTestUnbalancedQuotes01\"; "
"pcre:\"/\\/[a-z]+\\.php\\?[a-z]+?=\\d{7}&[a-z]+?=\\d{7,8}$/U\" "
"flowbits:set,et.exploitkitlanding; classtype:trojan-activity; sid:2017078; rev:5;)");
FAIL_IF_NOT_NULL(s);
DetectEngineCtxFree(de_ctx);
PASS;
}
@ -5148,13 +5144,12 @@ static int SigParseTestContentGtDsize01(void)
DetectEngineCtx *de_ctx = DetectEngineCtxInit();
FAIL_IF_NULL(de_ctx);
de_ctx->flags |= DE_QUIET;
Signature *s = SigInit(de_ctx,
"alert http any any -> any any ("
"dsize:21; content:\"0123456789001234567890|00 00|\"; "
"sid:1; rev:1;)");
Signature *s =
DetectEngineAppendSig(de_ctx, "alert http any any -> any any ("
"dsize:21; content:\"0123456789001234567890|00 00|\"; "
"sid:1; rev:1;)");
FAIL_IF_NOT_NULL(s);
DetectEngineCtxFree(de_ctx);
PASS;
}
@ -5163,13 +5158,12 @@ static int SigParseTestContentGtDsize02(void)
DetectEngineCtx *de_ctx = DetectEngineCtxInit();
FAIL_IF_NULL(de_ctx);
de_ctx->flags |= DE_QUIET;
Signature *s = SigInit(de_ctx,
"alert http any any -> any any ("
"dsize:21; content:\"0123456789|00 00|\"; offset:10; "
"sid:1; rev:1;)");
Signature *s =
DetectEngineAppendSig(de_ctx, "alert http any any -> any any ("
"dsize:21; content:\"0123456789|00 00|\"; offset:10; "
"sid:1; rev:1;)");
FAIL_IF_NOT_NULL(s);
DetectEngineCtxFree(de_ctx);
PASS;
}

@ -740,7 +740,6 @@ static int SCClassConfTest04(void)
result &= (SCClassConfGetClasstype("bed-unknown", de_ctx) == NULL);
DetectEngineCtxFree(de_ctx);
return result;
}
@ -773,7 +772,6 @@ static int SCClassConfTest05(void)
result &= (SCClassConfGetClasstype("bed-unknown", de_ctx) == NULL);
DetectEngineCtxFree(de_ctx);
return result;
}

@ -749,7 +749,7 @@ int UTHMatchPackets(DetectEngineCtx *de_ctx, Packet **p, int num_packets)
* and others may not. That check will be outside
*/
DetectEngineThreadCtxDeinit(&th_v, (void *)det_ctx);
if (de_ctx != NULL) SigGroupCleanup(de_ctx);
StatsThreadCleanup(&th_v);
return result;
}

Loading…
Cancel
Save