From aa363a8144d2bcacba3bedebceaa6e7ef2c39bbb Mon Sep 17 00:00:00 2001 From: Anoop Saldanha Date: Tue, 26 Mar 2013 13:20:54 +0530 Subject: [PATCH] unittest to display #784. --- src/detect-engine-payload.c | 45 +++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) 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;