Bunch of mostly unittest related memleak fixes.

remotes/origin/master-1.0.x
Victor Julien 15 years ago
parent 227cc082a1
commit fbe87a3ad5

@ -446,6 +446,16 @@ DefragContextNew(void)
return dc;
}
void DefragContextDestroy(DefragContext *dc) {
if (dc == NULL)
return;
HashListTableFree(dc->frag_table);
PoolFree(dc->frag_pool);
PoolFree(dc->tracker_pool);
free(dc);
}
/**
* Insert a new IPv4 fragment into a tracker.
*
@ -926,6 +936,27 @@ Defrag6(DefragContext *dc, Packet *p)
return NULL;
}
void
DefragInit(void)
{
/* Initialize random value for hashing and hash table size. */
defrag_hash_rand = rand();
defrag_hash_size = DEFAULT_DEFRAG_HASH_SIZE;
/* Allocate the DefragContext. */
defrag_context = DefragContextNew();
if (defrag_context == NULL) {
SCLogError(SC_ERR_MEM_ALLOC,
"Failed to allocate memory for the Defrag module.");
exit(EXIT_FAILURE);
}
}
void DefragDestroy(void) {
DefragContextDestroy(defrag_context);
defrag_context = NULL;
}
#ifdef UNITTESTS
#define IP_MF 0x2000
@ -937,7 +968,7 @@ static Packet *
BuildTestPacket(uint16_t id, uint16_t off, int mf, const char content,
int content_len)
{
Packet *p;
Packet *p = NULL;
int hlen = 20;
int ttl = 64;
@ -970,23 +1001,27 @@ BuildTestPacket(uint16_t id, uint16_t off, int mf, const char content,
/* Self test. */
IPV4_CACHE_INIT(p);
if (IPV4_GET_VER(p) != 4)
return NULL;
goto error;
if (IPV4_GET_HLEN(p) != hlen)
return NULL;
goto error;
if (IPV4_GET_IPLEN(p) != hlen + content_len)
return NULL;
goto error;
if (IPV4_GET_IPID(p) != id)
return NULL;
goto error;
if (IPV4_GET_IPOFFSET(p) != off)
return NULL;
goto error;
if (IPV4_GET_MF(p) != mf)
return NULL;
goto error;
if (IPV4_GET_IPTTL(p) != ttl)
return NULL;
goto error;
if (IPV4_GET_IPPROTO(p) != IPPROTO_ICMP)
return NULL;
goto error;
return p;
error:
if (p != NULL)
free(p);
return NULL;
}
/**
@ -996,59 +1031,80 @@ BuildTestPacket(uint16_t id, uint16_t off, int mf, const char content,
static int
DefragInOrderSimpleTest(void)
{
DefragContext *dc;
Packet *p1, *p2, *p3;
Packet *reassembled;
DefragContext *dc = NULL;
Packet *p1 = NULL, *p2 = NULL, *p3 = NULL;
Packet *reassembled = NULL;
int id = 12;
int i;
int ret = 0;
DefragInit();
dc = DefragContextNew();
if (dc == NULL)
return 0;
goto end;
p1 = BuildTestPacket(id, 0, 1, 'A', 8);
if (p1 == NULL)
return 0;
goto end;
p2 = BuildTestPacket(id, 1, 1, 'B', 8);
if (p2 == NULL)
return 0;
goto end;
p3 = BuildTestPacket(id, 2, 0, 'C', 3);
if (p3 == NULL)
return 0;
goto end;
if (Defrag4(NULL, dc, p1) != NULL)
return 0;
goto end;
if (Defrag4(NULL, dc, p2) != NULL)
return 0;
goto end;
reassembled = Defrag4(NULL, dc, p3);
if (reassembled == NULL)
return 0;
goto end;
/* 20 bytes in we should find 8 bytes of A. */
for (i = 20; i < 20 + 8; i++) {
if (reassembled->pkt[i] != 'A')
return 0;
goto end;
}
/* 28 bytes in we should find 8 bytes of B. */
for (i = 28; i < 28 + 8; i++) {
if (reassembled->pkt[i] != 'B')
return 0;
goto end;
}
/* And 36 bytes in we should find 3 bytes of C. */
for (i = 36; i < 36 + 3; i++) {
if (reassembled->pkt[i] != 'C')
return 0;
goto end;
}
return 1;
ret = 1;
end:
if (dc != NULL)
DefragContextDestroy(dc);
if (p1 != NULL)
free(p1);
if (p2 != NULL)
free(p2);
if (p3 != NULL)
free(p3);
if (reassembled != NULL)
free(reassembled);
DefragDestroy();
return ret;
}
static int
DefragDoSturgesNovakTest(int policy, u_char *expected, size_t expected_len)
{
int i;
int ret = 0;
DefragContext *dc = NULL;
DefragInit();
/*
* Build the packets.
@ -1056,6 +1112,7 @@ DefragDoSturgesNovakTest(int policy, u_char *expected, size_t expected_len)
int id = 1;
Packet *packets[17];
memset(packets, 0x00, sizeof(packets));
/*
* Original fragments.
@ -1116,26 +1173,37 @@ DefragDoSturgesNovakTest(int policy, u_char *expected, size_t expected_len)
/* Q*16 at 176. */
packets[16] = BuildTestPacket(id, 176 >> 3, 0, 'Q', 16);
DefragContext *dc = DefragContextNew();
dc = DefragContextNew();
if (dc == NULL)
return 0;
goto end;
dc->default_policy = policy;
/* Send all but the last. */
for (i = 0; i < 16; i++) {
if (Defrag4(NULL, dc, packets[i]) != NULL)
return 0;
Packet *tp = Defrag4(NULL, dc, packets[i]);
if (tp != NULL) {
free(tp);
goto end;
}
}
/* And now the last one. */
Packet *reassembled = Defrag4(NULL, dc, packets[16]);
if (reassembled == NULL)
return 0;
goto end;
if (memcmp(reassembled->pkt + 20, expected, expected_len) != 0)
return 0;
return 1;
goto end;
free(reassembled);
ret = 1;
end:
if (dc != NULL)
DefragContextDestroy(dc);
for (i = 0; i < 17; i++) {
free(packets[i]);
}
DefragDestroy();
return ret;
}
static int
@ -1346,33 +1414,55 @@ static int
DefragTimeoutTest(void)
{
int i;
int ret = 0;
DefragContext *dc = NULL;
DefragInit();
/* Setup a small numberr of trackers. */
ConfSet("defrag.trackers", "16", 1);
DefragContext *dc = DefragContextNew();
dc = DefragContextNew();
if (dc == NULL)
return 0;
goto end;
/* Load in 16 packets. */
for (i = 0; i < 16; i++) {
Packet *p = BuildTestPacket(i, 0, 1, 'A' + i, 16);
if (Defrag4(NULL, dc, p) != NULL)
return 0;
if (p == NULL)
goto end;
Packet *tp = Defrag4(NULL, dc, p);
free(p);
if (tp != NULL) {
free(tp);
goto end;
}
}
/* Build a new packet but push the timestamp out by our timeout.
* This should force our previous fragments to be timed out. */
Packet *p = BuildTestPacket(99, 0, 1, 'A' + i, 16);
if (p == NULL)
goto end;
p->ts.tv_sec += dc->timeout;
if (Defrag4(NULL, dc, p) != NULL)
return 0;
Packet *tp = Defrag4(NULL, dc, p);
free(p);
if (tp != NULL) {
free(tp);
goto end;
}
/* Iterate our HashList and look for the trackerr with id 99. */
int found = 0;
HashListTableBucket *next = HashListTableGetListHead(dc->frag_table);
if (next == NULL)
return 0;
goto end;
for (;;) {
if (next == NULL)
break;
@ -1385,9 +1475,14 @@ DefragTimeoutTest(void)
next = HashListTableGetListNext(next);
}
if (found == 0)
return 0;
return 1;
goto end;
ret = 1;
end:
if (dc != NULL)
DefragContextDestroy(dc);
DefragDestroy();
return ret;
}
#endif /* UNITTESTS */
@ -1415,18 +1510,3 @@ DefragRegisterTests(void)
#endif /* UNITTESTS */
}
void
DefragInit(void)
{
/* Initialize random value for hashing and hash table size. */
defrag_hash_rand = rand();
defrag_hash_size = DEFAULT_DEFRAG_HASH_SIZE;
/* Allocate the DefragContext. */
defrag_context = DefragContextNew();
if (defrag_context == NULL) {
SCLogError(SC_ERR_MEM_ALLOC,
"Failed to allocate memory for the Defrag module.");
exit(EXIT_FAILURE);
}
}

@ -213,7 +213,7 @@ static int DetectAckSigTest01Real(int mpm_type)
de_ctx->sig_list = SigInit(de_ctx,
"alert tcp any any -> any any "
"(msg:\"Testing ack\";sid:1;)");
"(msg:\"Testing ack\";ack:41;sid:1;)");
if (de_ctx->sig_list == NULL) {
goto cleanup_engine;
}

@ -17,6 +17,8 @@
#include "detect-content.h"
#include "detect-uricontent.h"
#include "util-debug.h"
/** \todo make it possible to use multiple pattern matcher algorithms next to
eachother. */
//#define PM MPM_WUMANBER
@ -71,13 +73,15 @@ void PacketPatternCleanup(ThreadVars *t, DetectEngineThreadCtx *det_ctx) {
}
}
void PatternMatchDestroy(MpmCtx *mc) {
mc->DestroyCtx(mc);
void PatternMatchDestroy(MpmCtx *mpm_ctx) {
SCLogDebug("mpm_ctx %p", mpm_ctx);
mpm_ctx->DestroyCtx(mpm_ctx);
}
void PatternMatchPrepare(MpmCtx *mc, int type)
{
MpmInitCtx(mc, type);
void PatternMatchPrepare(MpmCtx *mpm_ctx, int type) {
SCLogDebug("mpm_ctx %p, type %d", mpm_ctx, type);
memset(mpm_ctx, 0x00, sizeof(MpmCtx));
MpmInitCtx(mpm_ctx, type);
}
@ -86,6 +90,7 @@ void PatternMatchDestroyGroup(SigGroupHead *sh) {
/* content */
if (sh->flags & SIG_GROUP_HAVECONTENT && sh->mpm_ctx != NULL &&
!(sh->flags & SIG_GROUP_HEAD_MPM_COPY)) {
SCLogDebug("destroying mpm_ctx %p (sh %p)", sh->mpm_ctx, sh);
sh->mpm_ctx->DestroyCtx(sh->mpm_ctx);
free(sh->mpm_ctx);
@ -97,6 +102,7 @@ void PatternMatchDestroyGroup(SigGroupHead *sh) {
/* uricontent */
if (sh->flags & SIG_GROUP_HAVEURICONTENT && sh->mpm_uri_ctx != NULL &&
!(sh->flags & SIG_GROUP_HEAD_MPM_URI_COPY)) {
SCLogDebug("destroying mpm_uri_ctx %p (sh %p)", sh->mpm_uri_ctx, sh);
sh->mpm_uri_ctx->DestroyCtx(sh->mpm_uri_ctx);
free(sh->mpm_uri_ctx);
@ -503,6 +509,7 @@ int PatternMatchPrepareGroup(DetectEngineCtx *de_ctx, SigGroupHead *sh)
if (sh->mpm_ctx == NULL)
goto error;
memset(sh->mpm_ctx, 0x00, sizeof(MpmCtx));
MpmInitCtx(sh->mpm_ctx, PM);
}
if (sh->flags & SIG_GROUP_HAVEURICONTENT && !(sh->flags & SIG_GROUP_HEAD_MPM_URI_COPY)) {
@ -510,6 +517,7 @@ int PatternMatchPrepareGroup(DetectEngineCtx *de_ctx, SigGroupHead *sh)
if (sh->mpm_uri_ctx == NULL)
goto error;
memset(sh->mpm_uri_ctx, 0x00, sizeof(MpmCtx));
MpmInitCtx(sh->mpm_uri_ctx, PM);
}

@ -177,13 +177,8 @@ int DetectPortAdd(DetectPort **head, DetectPort *dp) {
int DetectPortInsertCopy(DetectEngineCtx *de_ctx, DetectPort **head, DetectPort *new) {
DetectPort *copy = DetectPortCopySingle(de_ctx,new);
//printf("new (%p): ", new); DetectPortPrint(new); printf(" "); DbgPrintSigs2(new->sh);
//printf("copy (%p): ",copy); DetectPortPrint(copy); printf(" "); DbgPrintSigs2(copy->sh);
if (copy != NULL) {
//printf("DetectPortInsertCopy: "); DetectPortPrint(copy); printf("\n");
}
if (copy == NULL)
return -1;
return DetectPortInsert(de_ctx, head, copy);
}
@ -730,11 +725,15 @@ DetectPort *DetectPortCopy(DetectEngineCtx *de_ctx, DetectPort *src) {
goto error;
}
memcpy(dst, src, sizeof(DetectPort));
dst->sh = NULL;
dst->port = src->port;
dst->port2 = src->port2;
if (src->next != NULL)
if (src->next != NULL) {
dst->next = DetectPortCopy(de_ctx, src->next);
if (dst->next != NULL) {
dst->next->prev = dst;
}
}
return dst;
error:
@ -750,10 +749,8 @@ DetectPort *DetectPortCopySingle(DetectEngineCtx *de_ctx,DetectPort *src) {
goto error;
}
memcpy(dst,src,sizeof(DetectPort));
dst->sh = NULL;
dst->next = NULL;
dst->prev = NULL;
dst->port = src->port;
dst->port2 = src->port2;
SigGroupHeadCopySigs(de_ctx,src->sh,&dst->sh);
@ -830,7 +827,7 @@ static int DetectPortParseInsert(DetectPort **head, DetectPort *new) {
}
static int DetectPortParseInsertString(DetectPort **head, char *s) {
DetectPort *ad = NULL;
DetectPort *ad = NULL, *ad_any = NULL;
int r = 0;
SCLogDebug("head %p, *head %p, s %s", head, *head, s);
@ -866,11 +863,11 @@ static int DetectPortParseInsertString(DetectPort **head, char *s) {
/* if any, insert 0.0.0.0/0 and ::/0 as well */
if (r == 1 && ad->flags & PORT_FLAG_ANY) {
ad = PortParse("0:65535");
if (ad == NULL)
ad_any = PortParse("0:65535");
if (ad_any == NULL)
goto error;
if (DetectPortParseInsert(head, ad) < 0)
if (DetectPortParseInsert(head, ad_any) < 0)
goto error;
}
@ -879,7 +876,9 @@ static int DetectPortParseInsertString(DetectPort **head, char *s) {
error:
printf("DetectPortParseInsertString error\n");
if (ad != NULL)
DetectPortFree(ad);
DetectPortCleanupList(ad);
if (ad_any != NULL)
DetectPortCleanupList(ad_any);
return -1;
}
@ -1002,7 +1001,7 @@ int DetectPortIsCompletePortSpace(DetectPort *p) {
/* part of the parsing routine */
int DetectPortParseMergeNotPorts(DetectPort **head, DetectPort **nhead) {
DetectPort *ad;
DetectPort *ad = NULL;
DetectPort *ag, *ag2;
int r = 0;
@ -1034,6 +1033,7 @@ int DetectPortParseMergeNotPorts(DetectPort **head, DetectPort **nhead) {
if (r < 0) {
goto error;
}
ad = NULL;
}
/* step 2: pull the address blocks that match our 'not' blocks */
@ -1078,6 +1078,8 @@ int DetectPortParseMergeNotPorts(DetectPort **head, DetectPort **nhead) {
return 0;
error:
if (ad != NULL)
DetectPortFree(ad);
return -1;
}
@ -1104,15 +1106,16 @@ int DetectPortParse(DetectPort **head, char *str) {
return 0;
error:
DetectPortFree(nhead);
DetectPortCleanupList(nhead);
return -1;
}
DetectPort *PortParse(char *str) {
char *portdup = strdup(str);
char *port2 = NULL;
DetectPort *dp = NULL;
DetectPort *dp = DetectPortInit();
dp = DetectPortInit();
if (dp == NULL)
goto error;
@ -1165,6 +1168,9 @@ DetectPort *PortParse(char *str) {
return dp;
error:
if (dp != NULL)
DetectPortCleanupList(dp);
if (portdup) free(portdup);
return NULL;
}
@ -1396,7 +1402,10 @@ int PortTestParse06 (void) {
result = 1;
end:
DetectPortCleanupList(dd);
if (copy != NULL)
DetectPortCleanupList(copy);
if (dd != NULL)
DetectPortCleanupList(dd);
return result;
}
@ -1529,6 +1538,57 @@ end:
}
int PortTestParse14 (void) {
DetectPort *dd = NULL, *copy = NULL;
int result = 0;
int r = DetectPortParse(&dd,"22");
if (r != 0)
goto end;
r = DetectPortParse(&dd,"80");
if (r != 0)
goto end;
r = DetectPortParse(&dd,"143");
if (r != 0)
goto end;
copy = DetectPortCopy(NULL,dd);
if (copy == NULL)
goto end;
if (DetectPortCmp(dd,copy) != PORT_EQ)
goto end;
if (copy->next == NULL)
goto end;
if (DetectPortCmp(dd->next,copy->next) != PORT_EQ)
goto end;
if (copy->next->next == NULL)
goto end;
if (DetectPortCmp(dd->next->next,copy->next->next) != PORT_EQ)
goto end;
if (copy->port != 22 || copy->next->port != 80 || copy->next->next->port != 143)
goto end;
if (copy->next->prev != copy)
goto end;
result = 1;
end:
if (copy != NULL)
DetectPortCleanupList(copy);
if (dd != NULL)
DetectPortCleanupList(dd);
return result;
}
#endif /* UNITTESTS */
void DetectPortTests(void) {
@ -1546,6 +1606,7 @@ void DetectPortTests(void) {
UtRegisterTest("PortTestParse11", PortTestParse11, 1);
UtRegisterTest("PortTestParse12", PortTestParse12, 1);
UtRegisterTest("PortTestParse13", PortTestParse13, 1);
UtRegisterTest("PortTestParse14", PortTestParse14, 1);
#endif /* UNITTESTS */
}

@ -345,19 +345,19 @@ static int DetectProtoTestSig01(void) {
de_ctx->flags |= DE_QUIET;
s = de_ctx->sig_list = SigInit(de_ctx,"alert udp any any -> any any "
"(msg:\"Not tcp\"; sid:1;)");
"(msg:\"Not tcp\"; flow:to_server; sid:1;)");
if (s == NULL)
goto end;
s = s->next = SigInit(de_ctx,"alert ip any any -> any any "
"(msg:\"IP\"; sid:2;)");
"(msg:\"IP\"; flow:to_server; sid:2;)");
if (s == NULL)
goto end;
s = s->next = SigInit(de_ctx,"alert tcp any any -> any any "
"(msg:\"TCP\"; sid:3;)");
"(msg:\"TCP\"; flow:to_server; sid:3;)");
if (s == NULL)
goto end;

@ -23,6 +23,8 @@
#include "util-hash.h"
#include "util-hashlist.h"
#include "util-debug.h"
/* prototypes */
int SigGroupHeadClearSigs(SigGroupHead *);
@ -74,6 +76,8 @@ error:
/** \brief Free a sgh
* \param sgh the sig group head to free */
void SigGroupHeadFree(SigGroupHead *sgh) {
SCLogDebug("sgh %p", sgh);
if (sgh == NULL)
return;

@ -49,6 +49,8 @@ error:
void DetectEngineCtxFree(DetectEngineCtx *de_ctx) {
SigCleanSignatures(de_ctx);
/* Normally the hashes are freed elsewhere, but
* to be sure look at them again here.
*/
@ -62,6 +64,8 @@ void DetectEngineCtxFree(DetectEngineCtx *de_ctx) {
DetectPortDpHashFree(de_ctx);
VariableNameFreeHash(de_ctx);
if (de_ctx->sig_array)
free(de_ctx->sig_array);
free(de_ctx);
}

@ -449,7 +449,15 @@ int SigParseBasics(Signature *s, char *sigstr, char ***result) {
return 0;
error:
if (arr) free(arr);
if (arr != NULL) {
for (i = 1; i <= ret - 1; i++) {
if (arr[i - 1] == NULL)
continue;
pcre_free_substring(arr[i - 1]);
}
free(arr);
}
*result = NULL;
return -1;
}
@ -513,6 +521,9 @@ void SigFree(Signature *s) {
DetectAddressGroupsHeadCleanup(&s->src);
DetectAddressGroupsHeadCleanup(&s->dst);
DetectPortCleanupList(s->sp);
DetectPortCleanupList(s->dp);
if (s->msg != NULL) free(s->msg);
free(s);
@ -598,6 +609,7 @@ int SigParseTest02 (void) {
DetectPortPrint(port); printf(" != "); DetectPortPrint(sig->sp); printf(": ");
}
DetectPortCleanupList(port);
SigFree(sig);
DetectEngineCtxFree(de_ctx);
end:

@ -144,16 +144,9 @@ static int DetectSameipSigTest01Real(int mpm_type)
de_ctx->flags |= DE_QUIET;
de_ctx->sig_list = SigInit(de_ctx,
"alert tcp any any -> any any "
"(msg:\"Testing sameip\";sid:1;)");
if (de_ctx->sig_list == NULL) {
goto end;
}
de_ctx->sig_list->next = SigInit(de_ctx,
"alert tcp any any -> any any "
"(msg:\"Testing sameip\";sameip;sid:2;)");
if (de_ctx->sig_list->next == NULL) {
"(msg:\"Testing sameip\"; sameip; sid:1;)");
if (de_ctx->sig_list == NULL) {
goto end;
}
@ -162,21 +155,13 @@ static int DetectSameipSigTest01Real(int mpm_type)
DetectEngineThreadCtxInit(&th_v, (void *)de_ctx, (void *)&det_ctx);
SigMatchSignatures(&th_v, de_ctx, det_ctx, &p[0]);
if (PacketAlertCheck(&p[0], 1) != 0) {
printf("sid 1 alerted, but should not have: ");
goto cleanup;
}
if (PacketAlertCheck(&p[0], 2) == 0) {
if (PacketAlertCheck(&p[0], 1) == 0) {
printf("sid 2 did not alert, but should have: ");
goto cleanup;
}
SigMatchSignatures(&th_v, de_ctx, det_ctx, &p[1]);
if (PacketAlertCheck(&p[1], 1) != 0) {
printf("sid 1 alerted, but should not have: ");
goto cleanup;
}
if (PacketAlertCheck(&p[1], 2) != 0) {
printf("sid 2 alerted, but should not have: ");
goto cleanup;
}

@ -213,7 +213,7 @@ static int DetectSeqSigTest01Real(int mpm_type)
de_ctx->sig_list = SigInit(de_ctx,
"alert tcp any any -> any any "
"(msg:\"Testing seq\";sid:1;)");
"(msg:\"Testing seq\";seq:41;sid:1;)");
if (de_ctx->sig_list == NULL) {
goto cleanup_engine;
}

@ -587,6 +587,7 @@ void SigCleanSignatures(DetectEngineCtx *de_ctx)
}
DetectEngineResetMaxSigId(de_ctx);
de_ctx->sig_list = NULL;
}
/** \brief Test is a initialized signature is IP only
@ -6277,7 +6278,7 @@ int SigTest40NoPacketInspection01(void) {
de_ctx->flags |= DE_QUIET;
de_ctx->sig_list = SigInit(de_ctx,"alert tcp any any -> 1.2.3.4 any (msg:\"No Packet Inspection Test\"; sid:2; rev:1;)");
de_ctx->sig_list = SigInit(de_ctx,"alert tcp any any -> 1.2.3.4 any (msg:\"No Packet Inspection Test\"; flow:to_server; sid:2; rev:1;)");
if (de_ctx->sig_list == NULL) {
result = 0;
goto end;

@ -391,8 +391,6 @@ int main(int argc, char **argv)
PatternMatchPrepare(mpm_ctx, MPM_B2G);
PerfInitCounterApi();
DefragInit();
/** \todo we need an api for these */
AppLayerDetectProtoThreadInit();
RegisterAppLayerParsers();
@ -546,6 +544,7 @@ int main(int argc, char **argv)
FlowManagerThreadSpawn();
StreamTcpInitConfig(STREAM_VERBOSE);
DefragInit();
/* Spawn the L7 App Detect thread */
//AppLayerDetectProtoThreadSpawn();

@ -21,6 +21,7 @@
#include "util-mpm-b2g.h"
#include "util-print.h"
#include "util-debug.h"
#include "util-unittest.h"
#define INIT_HASH_SIZE 65536
@ -888,7 +889,9 @@ memcmp_lowercase(uint8_t *s1, uint8_t *s2, uint16_t n) {
}
void B2gInitCtx (MpmCtx *mpm_ctx) {
//printf("B2gInitCtx: mpm_ctx %p\n", mpm_ctx);
SCLogDebug("mpm_ctx %p, ctx %p", mpm_ctx, mpm_ctx->ctx);
BUG_ON(mpm_ctx->ctx != NULL);
memset(mpm_ctx, 0, sizeof(MpmCtx));
@ -911,6 +914,8 @@ void B2gInitCtx (MpmCtx *mpm_ctx) {
}
void B2gDestroyCtx(MpmCtx *mpm_ctx) {
SCLogDebug("mpm_ctx %p", mpm_ctx);
B2gCtx *ctx = (B2gCtx *)mpm_ctx->ctx;
if (ctx == NULL)
return;
@ -1744,6 +1749,7 @@ uint32_t B2gSearch1(MpmCtx *mpm_ctx, MpmThreadCtx *mpm_thread_ctx, PatternMatche
static int B2gTestInit01 (void) {
int result = 0;
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
MpmInitCtx(&mpm_ctx, MPM_B2G);
B2gCtx *ctx = (B2gCtx *)mpm_ctx.ctx;
@ -1862,6 +1868,7 @@ static int B2gTestS0Init05 (void) {
static int B2gTestScan01 (void) {
int result = 0;
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
MpmThreadCtx mpm_thread_ctx;
MpmInitCtx(&mpm_ctx, MPM_B2G);
@ -1887,6 +1894,7 @@ static int B2gTestScan01 (void) {
static int B2gTestScan02 (void) {
int result = 0;
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
MpmThreadCtx mpm_thread_ctx;
MpmInitCtx(&mpm_ctx, MPM_B2G);
@ -1912,6 +1920,7 @@ static int B2gTestScan02 (void) {
static int B2gTestScan03 (void) {
int result = 0;
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
MpmThreadCtx mpm_thread_ctx;
MpmInitCtx(&mpm_ctx, MPM_B2G);
@ -1940,6 +1949,7 @@ static int B2gTestScan03 (void) {
static int B2gTestScan04 (void) {
int result = 0;
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
MpmThreadCtx mpm_thread_ctx;
MpmInitCtx(&mpm_ctx, MPM_B2G);
@ -1968,6 +1978,7 @@ static int B2gTestScan04 (void) {
static int B2gTestScan05 (void) {
int result = 0;
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
MpmThreadCtx mpm_thread_ctx;
MpmInitCtx(&mpm_ctx, MPM_B2G);
@ -1995,6 +2006,7 @@ static int B2gTestScan05 (void) {
static int B2gTestScan06 (void) {
int result = 0;
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
MpmThreadCtx mpm_thread_ctx;
MpmInitCtx(&mpm_ctx, MPM_B2G);
@ -2020,6 +2032,7 @@ static int B2gTestScan06 (void) {
static int B2gTestScan07 (void) {
int result = 0;
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
MpmThreadCtx mpm_thread_ctx;
MpmInitCtx(&mpm_ctx, MPM_B2G);
//B2gCtx *ctx = (B2gCtx *)mpm_ctx.ctx;
@ -2052,6 +2065,7 @@ static int B2gTestScan07 (void) {
static int B2gTestScan08 (void) {
int result = 0;
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
MpmThreadCtx mpm_thread_ctx;
MpmInitCtx(&mpm_ctx, MPM_B2G);
@ -2077,6 +2091,7 @@ static int B2gTestScan08 (void) {
static int B2gTestScan09 (void) {
int result = 0;
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
MpmThreadCtx mpm_thread_ctx;
MpmInitCtx(&mpm_ctx, MPM_B2G);
@ -2102,6 +2117,7 @@ static int B2gTestScan09 (void) {
static int B2gTestScan10 (void) {
int result = 0;
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
MpmThreadCtx mpm_thread_ctx;
MpmInitCtx(&mpm_ctx, MPM_B2G);
@ -2127,6 +2143,7 @@ static int B2gTestScan10 (void) {
static int B2gTestScan11 (void) {
int result = 0;
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
MpmThreadCtx mpm_thread_ctx;
MpmInitCtx(&mpm_ctx, MPM_B2G);
@ -2153,6 +2170,7 @@ static int B2gTestScan11 (void) {
static int B2gTestScan12 (void) {
int result = 0;
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
MpmThreadCtx mpm_thread_ctx;
MpmInitCtx(&mpm_ctx, MPM_B2G);
@ -2179,6 +2197,7 @@ static int B2gTestScan12 (void) {
static int B2gTestSearch01 (void) {
int result = 0;
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
MpmThreadCtx mpm_thread_ctx;
MpmInitCtx(&mpm_ctx, MPM_B2G);
@ -2204,6 +2223,7 @@ static int B2gTestSearch01 (void) {
static int B2gTestSearch02 (void) {
int result = 0;
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
MpmThreadCtx mpm_thread_ctx;
MpmInitCtx(&mpm_ctx, MPM_B2G);
@ -2229,6 +2249,7 @@ static int B2gTestSearch02 (void) {
static int B2gTestSearch03 (void) {
int result = 0;
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
MpmThreadCtx mpm_thread_ctx;
MpmInitCtx(&mpm_ctx, MPM_B2G);
@ -2257,6 +2278,7 @@ static int B2gTestSearch03 (void) {
static int B2gTestSearch04 (void) {
int result = 0;
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
MpmThreadCtx mpm_thread_ctx;
MpmInitCtx(&mpm_ctx, MPM_B2G);
@ -2285,6 +2307,7 @@ static int B2gTestSearch04 (void) {
static int B2gTestSearch05 (void) {
int result = 0;
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
MpmThreadCtx mpm_thread_ctx;
MpmInitCtx(&mpm_ctx, MPM_B2G);
@ -2312,6 +2335,7 @@ static int B2gTestSearch05 (void) {
static int B2gTestSearch06 (void) {
int result = 0;
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
MpmThreadCtx mpm_thread_ctx;
MpmInitCtx(&mpm_ctx, MPM_B2G);
@ -2337,6 +2361,7 @@ static int B2gTestSearch06 (void) {
static int B2gTestSearch07 (void) {
int result = 0;
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
MpmThreadCtx mpm_thread_ctx;
MpmInitCtx(&mpm_ctx, MPM_B2G);
//B2gCtx *ctx = (B2gCtx *)mpm_ctx.ctx;
@ -2369,6 +2394,7 @@ static int B2gTestSearch07 (void) {
static int B2gTestSearch08 (void) {
int result = 0;
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
MpmThreadCtx mpm_thread_ctx;
MpmInitCtx(&mpm_ctx, MPM_B2G);
@ -2394,6 +2420,7 @@ static int B2gTestSearch08 (void) {
static int B2gTestSearch09 (void) {
int result = 0;
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
MpmThreadCtx mpm_thread_ctx;
MpmInitCtx(&mpm_ctx, MPM_B2G);
@ -2419,6 +2446,7 @@ static int B2gTestSearch09 (void) {
static int B2gTestSearch10 (void) {
int result = 0;
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
MpmThreadCtx mpm_thread_ctx;
MpmInitCtx(&mpm_ctx, MPM_B2G);
@ -2444,6 +2472,7 @@ static int B2gTestSearch10 (void) {
static int B2gTestSearch11 (void) {
int result = 0;
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
MpmThreadCtx mpm_thread_ctx;
MpmInitCtx(&mpm_ctx, MPM_B2G);
@ -2470,6 +2499,7 @@ static int B2gTestSearch11 (void) {
static int B2gTestSearch12 (void) {
int result = 0;
MpmCtx mpm_ctx;
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
MpmThreadCtx mpm_thread_ctx;
MpmInitCtx(&mpm_ctx, MPM_B2G);

Loading…
Cancel
Save