Bug #10 » 0001-unit-test-showing-flags-0-alerting-when-it-shouldn-t.patch
| src/detect-flags.c | ||
|---|---|---|
|
if (sm) free(sm);
|
||
|
return 0;
|
||
|
}
|
||
|
/**
|
||
|
* \test FlagsTestParse12 check if no flags are set. Must fails.
|
||
|
*
|
||
|
* \retval 1 on succces
|
||
|
* \retval 0 on failure
|
||
|
*/
|
||
|
static int FlagsTestParse12 (void) {
|
||
|
Packet p;
|
||
|
ThreadVars tv;
|
||
|
int ret = 0;
|
||
|
DetectFlagsData *de = NULL;
|
||
|
SigMatch *sm = NULL;
|
||
|
IPV4Hdr ipv4h;
|
||
|
TCPHdr tcph;
|
||
|
memset(&tv, 0, sizeof(ThreadVars));
|
||
|
memset(&p, 0, sizeof(Packet));
|
||
|
memset(&ipv4h, 0, sizeof(IPV4Hdr));
|
||
|
memset(&tcph, 0, sizeof(TCPHdr));
|
||
|
p.ip4h = &ipv4h;
|
||
|
p.tcph = &tcph;
|
||
|
p.tcph->th_flags = TH_SYN;
|
||
|
de = DetectFlagsParse("0");
|
||
|
if (de == NULL || de->flags != 0)
|
||
|
goto error;
|
||
|
sm = SigMatchAlloc();
|
||
|
if (sm == NULL)
|
||
|
goto error;
|
||
|
sm->type = DETECT_FLAGS;
|
||
|
sm->ctx = (void *)de;
|
||
|
ret = DetectFlagsMatch(&tv,NULL,&p,NULL,sm);
|
||
|
if(ret) {
|
||
|
if (de) free(de);
|
||
|
if (sm) free(sm);
|
||
|
return 1;
|
||
|
}
|
||
|
error:
|
||
|
if (de) free(de);
|
||
|
if (sm) free(sm);
|
||
|
return 0;
|
||
|
}
|
||
|
#endif /* UNITTESTS */
|
||
|
/**
|
||
| ... | ... | |
|
UtRegisterTest("FlagsTestParse09", FlagsTestParse09, 1);
|
||
|
UtRegisterTest("FlagsTestParse10", FlagsTestParse10, 1);
|
||
|
UtRegisterTest("FlagsTestParse11", FlagsTestParse11, 0);
|
||
|
UtRegisterTest("FlagsTestParse12", FlagsTestParse12, 0);
|
||
|
#endif /* UNITTESTS */
|
||
|
}
|
||