From: Anoop Saldanha Date: Tue, 26 Mar 2013 07:50:54 +0000 (+0530) Subject: unittest to display #784. X-Git-Tag: suricata-2.0beta1~193 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=aa363a8144d2bcacba3bedebceaa6e7ef2c39bbb;p=thirdparty%2Fsuricata.git unittest to display #784. --- diff --git a/src/detect-engine-payload.c b/src/detect-engine-payload.c index 64dfe73659..40a1c178e9 100644 --- a/src/detect-engine-payload.c +++ b/src/detect-engine-payload.c @@ -955,6 +955,48 @@ end: return result; } +static int PayloadTestSig30(void) +{ + uint8_t *buf = (uint8_t *) + "xyonexxxxxxtwojunkonetwo"; + uint16_t buflen = strlen((char *)buf); + Packet *p = UTHBuildPacket( buf, buflen, IPPROTO_TCP); + int result = 0; + + char sig[] = "alert tcp any any -> any any (content:\"one\"; pcre:\"/^two/R\"; sid:1;)"; + if (UTHPacketMatchSigMpm(p, sig, MPM_B2G) == 0) { + result = 0; + goto end; + } + + result = 1; +end: + if (p != NULL) + UTHFreePacket(p); + return result; +} + +static int PayloadTestSig31(void) +{ + uint8_t *buf = (uint8_t *) + "xyonexxxxxxtwojunkonetwo"; + uint16_t buflen = strlen((char *)buf); + Packet *p = UTHBuildPacket( buf, buflen, IPPROTO_TCP); + int result = 0; + + char sig[] = "alert tcp any any -> any any (content:\"one\"; pcre:\"/(fiv|^two)/R\"; sid:1;)"; + if (UTHPacketMatchSigMpm(p, sig, MPM_B2G) == 0) { + result = 0; + goto end; + } + + result = 1; +end: + if (p != NULL) + UTHFreePacket(p); + return result; +} + #endif /* UNITTESTS */ void PayloadRegisterTests(void) { @@ -989,6 +1031,9 @@ void PayloadRegisterTests(void) { UtRegisterTest("PayloadTestSig27", PayloadTestSig27, 1); UtRegisterTest("PayloadTestSig28", PayloadTestSig28, 1); UtRegisterTest("PayloadTestSig29", PayloadTestSig29, 1); + + UtRegisterTest("PayloadTestSig30", PayloadTestSig30, 1); + UtRegisterTest("PayloadTestSig31", PayloadTestSig31, 1); #endif /* UNITTESTS */ return;