From: Anoop Saldanha Date: Mon, 24 Sep 2012 10:32:07 +0000 (+0530) Subject: Unittest to display #bug 529. pcre anchor not respected X-Git-Tag: suricata-1.4beta2~42 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=19e8f82f25e86acba85244ace3039110489f8c4b;p=thirdparty%2Fsuricata.git Unittest to display #bug 529. pcre anchor not respected --- diff --git a/src/detect-engine-payload.c b/src/detect-engine-payload.c index 2745e0c6a6..b6b507cf55 100644 --- a/src/detect-engine-payload.c +++ b/src/detect-engine-payload.c @@ -931,6 +931,31 @@ end: return result; } +/** + * \test Test pcre recursive matching - bug #529 + */ +static int PayloadTestSig29(void) +{ + uint8_t *buf = (uint8_t *)"this is a super dupernova in super nova now"; + uint16_t buflen = strlen((char *)buf); + Packet *p = UTHBuildPacket( buf, buflen, IPPROTO_TCP); + int result = 0; + + char sig[] = "alert tcp any any -> any any (msg:\"dummy\"; " + "pcre:/^.{4}/; content:\"nova\"; within:4; sid:1;)"; + + if (UTHPacketMatchSigMpm(p, sig, MPM_AC) == 1) { + result = 0; + goto end; + } + + result = 1; +end: + if (p != NULL) + UTHFreePacket(p); + return result; +} + #endif /* UNITTESTS */ void PayloadRegisterTests(void) { @@ -964,6 +989,7 @@ void PayloadRegisterTests(void) { UtRegisterTest("PayloadTestSig26", PayloadTestSig26, 1); UtRegisterTest("PayloadTestSig27", PayloadTestSig27, 1); UtRegisterTest("PayloadTestSig28", PayloadTestSig28, 1); + UtRegisterTest("PayloadTestSig29", PayloadTestSig29, 1); #endif /* UNITTESTS */ return;