@ -41,7 +41,7 @@
# include "util-unittest.h"
# include "util-unittest.h"
# include "util-print.h"
# include "util-print.h"
# include "util-debug.h"
# include "util-debug.h"
# include "util-spm -bm .h"
# include "util-spm .h"
# include "threads.h"
# include "threads.h"
# include "util-unittest-helper.h"
# include "util-unittest-helper.h"
# include "pkt-var.h"
# include "pkt-var.h"
@ -217,7 +217,8 @@ error:
* \ brief DetectContentParse
* \ brief DetectContentParse
* \ initonly
* \ initonly
*/
*/
DetectContentData * DetectContentParse ( char * contentstr )
DetectContentData * DetectContentParse ( SpmGlobalThreadCtx * spm_global_thread_ctx ,
char * contentstr )
{
{
DetectContentData * cd = NULL ;
DetectContentData * cd = NULL ;
uint8_t * content = NULL ;
uint8_t * content = NULL ;
@ -245,8 +246,15 @@ DetectContentData *DetectContentParse (char *contentstr)
memcpy ( cd - > content , content , len ) ;
memcpy ( cd - > content , content , len ) ;
cd - > content_len = len ;
cd - > content_len = len ;
/* Prepare Boyer Moore context for searching faster */
/* Prepare SPM search context. */
cd - > bm_ctx = BoyerMooreCtxInit ( cd - > content , cd - > content_len ) ;
cd - > spm_ctx = SpmInitCtx ( cd - > content , cd - > content_len , 0 ,
spm_global_thread_ctx ) ;
if ( cd - > spm_ctx = = NULL ) {
SCFree ( content ) ;
SCFree ( cd ) ;
return NULL ;
}
cd - > depth = 0 ;
cd - > depth = 0 ;
cd - > offset = 0 ;
cd - > offset = 0 ;
cd - > within = 0 ;
cd - > within = 0 ;
@ -257,7 +265,8 @@ DetectContentData *DetectContentParse (char *contentstr)
}
}
DetectContentData * DetectContentParseEncloseQuotes ( char * contentstr )
DetectContentData * DetectContentParseEncloseQuotes ( SpmGlobalThreadCtx * spm_global_thread_ctx ,
char * contentstr )
{
{
char str [ strlen ( contentstr ) + 3 ] ; // 2 for quotes, 1 for \0
char str [ strlen ( contentstr ) + 3 ] ; // 2 for quotes, 1 for \0
@ -266,7 +275,7 @@ DetectContentData *DetectContentParseEncloseQuotes(char *contentstr)
str [ strlen ( contentstr ) + 1 ] = ' \" ' ;
str [ strlen ( contentstr ) + 1 ] = ' \" ' ;
str [ strlen ( contentstr ) + 2 ] = ' \0 ' ;
str [ strlen ( contentstr ) + 2 ] = ' \0 ' ;
return DetectContentParse ( s tr) ;
return DetectContentParse ( s pm_global_thread_ctx, s tr) ;
}
}
/**
/**
@ -370,7 +379,7 @@ int DetectContentSetup(DetectEngineCtx *de_ctx, Signature *s, char *contentstr)
DetectContentData * cd = NULL ;
DetectContentData * cd = NULL ;
SigMatch * sm = NULL ;
SigMatch * sm = NULL ;
cd = DetectContentParse ( contentstr) ;
cd = DetectContentParse ( de_ctx- > spm_global_thread_ctx , contentstr) ;
if ( cd = = NULL )
if ( cd = = NULL )
goto error ;
goto error ;
DetectContentPrint ( cd ) ;
DetectContentPrint ( cd ) ;
@ -415,7 +424,7 @@ void DetectContentFree(void *ptr)
if ( cd = = NULL )
if ( cd = = NULL )
SCReturn ;
SCReturn ;
BoyerMooreCtxDeInit( cd - > b m_ctx) ;
SpmDestroyCtx( cd - > sp m_ctx) ;
SCFree ( cd ) ;
SCFree ( cd ) ;
SCReturn ;
SCReturn ;
@ -433,7 +442,11 @@ int DetectContentParseTest01 (void)
char * teststring = " \" abc \\ :def \" " ;
char * teststring = " \" abc \\ :def \" " ;
char * teststringparsed = " abc:def " ;
char * teststringparsed = " abc:def " ;
cd = DetectContentParse ( teststring ) ;
uint16_t spm_matcher = SinglePatternMatchDefaultMatcher ( ) ;
SpmGlobalThreadCtx * spm_global_thread_ctx = SpmInitGlobalThreadCtx ( spm_matcher ) ;
FAIL_IF ( spm_global_thread_ctx = = NULL ) ;
cd = DetectContentParse ( spm_global_thread_ctx , teststring ) ;
if ( cd ! = NULL ) {
if ( cd ! = NULL ) {
if ( memcmp ( cd - > content , teststringparsed , strlen ( teststringparsed ) ) ! = 0 ) {
if ( memcmp ( cd - > content , teststringparsed , strlen ( teststringparsed ) ) ! = 0 ) {
SCLogDebug ( " expected %s got " , teststringparsed ) ;
SCLogDebug ( " expected %s got " , teststringparsed ) ;
@ -446,6 +459,7 @@ int DetectContentParseTest01 (void)
SCLogDebug ( " expected %s got NULL: " , teststringparsed ) ;
SCLogDebug ( " expected %s got NULL: " , teststringparsed ) ;
result = 0 ;
result = 0 ;
}
}
SpmDestroyGlobalThreadCtx ( spm_global_thread_ctx ) ;
return result ;
return result ;
}
}
@ -459,7 +473,11 @@ int DetectContentParseTest02 (void)
char * teststring = " \" abc \\ ;def \" " ;
char * teststring = " \" abc \\ ;def \" " ;
char * teststringparsed = " abc;def " ;
char * teststringparsed = " abc;def " ;
cd = DetectContentParse ( teststring ) ;
uint16_t spm_matcher = SinglePatternMatchDefaultMatcher ( ) ;
SpmGlobalThreadCtx * spm_global_thread_ctx = SpmInitGlobalThreadCtx ( spm_matcher ) ;
FAIL_IF ( spm_global_thread_ctx = = NULL ) ;
cd = DetectContentParse ( spm_global_thread_ctx , teststring ) ;
if ( cd ! = NULL ) {
if ( cd ! = NULL ) {
if ( memcmp ( cd - > content , teststringparsed , strlen ( teststringparsed ) ) ! = 0 ) {
if ( memcmp ( cd - > content , teststringparsed , strlen ( teststringparsed ) ) ! = 0 ) {
SCLogDebug ( " expected %s got " , teststringparsed ) ;
SCLogDebug ( " expected %s got " , teststringparsed ) ;
@ -472,6 +490,7 @@ int DetectContentParseTest02 (void)
SCLogDebug ( " expected %s got NULL: " , teststringparsed ) ;
SCLogDebug ( " expected %s got NULL: " , teststringparsed ) ;
result = 0 ;
result = 0 ;
}
}
SpmDestroyGlobalThreadCtx ( spm_global_thread_ctx ) ;
return result ;
return result ;
}
}
@ -485,7 +504,11 @@ int DetectContentParseTest03 (void)
char * teststring = " \" abc \\ \" def \" " ;
char * teststring = " \" abc \\ \" def \" " ;
char * teststringparsed = " abc \" def " ;
char * teststringparsed = " abc \" def " ;
cd = DetectContentParse ( teststring ) ;
uint16_t spm_matcher = SinglePatternMatchDefaultMatcher ( ) ;
SpmGlobalThreadCtx * spm_global_thread_ctx = SpmInitGlobalThreadCtx ( spm_matcher ) ;
FAIL_IF ( spm_global_thread_ctx = = NULL ) ;
cd = DetectContentParse ( spm_global_thread_ctx , teststring ) ;
if ( cd ! = NULL ) {
if ( cd ! = NULL ) {
if ( memcmp ( cd - > content , teststringparsed , strlen ( teststringparsed ) ) ! = 0 ) {
if ( memcmp ( cd - > content , teststringparsed , strlen ( teststringparsed ) ) ! = 0 ) {
SCLogDebug ( " expected %s got " , teststringparsed ) ;
SCLogDebug ( " expected %s got " , teststringparsed ) ;
@ -498,6 +521,7 @@ int DetectContentParseTest03 (void)
SCLogDebug ( " expected %s got NULL: " , teststringparsed ) ;
SCLogDebug ( " expected %s got NULL: " , teststringparsed ) ;
result = 0 ;
result = 0 ;
}
}
SpmDestroyGlobalThreadCtx ( spm_global_thread_ctx ) ;
return result ;
return result ;
}
}
@ -511,7 +535,11 @@ int DetectContentParseTest04 (void)
char * teststring = " \" abc \\ \\ def \" " ;
char * teststring = " \" abc \\ \\ def \" " ;
char * teststringparsed = " abc \\ def " ;
char * teststringparsed = " abc \\ def " ;
cd = DetectContentParse ( teststring ) ;
uint16_t spm_matcher = SinglePatternMatchDefaultMatcher ( ) ;
SpmGlobalThreadCtx * spm_global_thread_ctx = SpmInitGlobalThreadCtx ( spm_matcher ) ;
FAIL_IF ( spm_global_thread_ctx = = NULL ) ;
cd = DetectContentParse ( spm_global_thread_ctx , teststring ) ;
if ( cd ! = NULL ) {
if ( cd ! = NULL ) {
uint16_t len = ( cd - > content_len > strlen ( teststringparsed ) ) ;
uint16_t len = ( cd - > content_len > strlen ( teststringparsed ) ) ;
if ( memcmp ( cd - > content , teststringparsed , len ) ! = 0 ) {
if ( memcmp ( cd - > content , teststringparsed , len ) ! = 0 ) {
@ -525,6 +553,7 @@ int DetectContentParseTest04 (void)
SCLogDebug ( " expected %s got NULL: " , teststringparsed ) ;
SCLogDebug ( " expected %s got NULL: " , teststringparsed ) ;
result = 0 ;
result = 0 ;
}
}
SpmDestroyGlobalThreadCtx ( spm_global_thread_ctx ) ;
return result ;
return result ;
}
}
@ -537,7 +566,11 @@ int DetectContentParseTest05 (void)
DetectContentData * cd = NULL ;
DetectContentData * cd = NULL ;
char * teststring = " \" abc \\ def \" " ;
char * teststring = " \" abc \\ def \" " ;
cd = DetectContentParse ( teststring ) ;
uint16_t spm_matcher = SinglePatternMatchDefaultMatcher ( ) ;
SpmGlobalThreadCtx * spm_global_thread_ctx = SpmInitGlobalThreadCtx ( spm_matcher ) ;
FAIL_IF ( spm_global_thread_ctx = = NULL ) ;
cd = DetectContentParse ( spm_global_thread_ctx , teststring ) ;
if ( cd ! = NULL ) {
if ( cd ! = NULL ) {
SCLogDebug ( " expected NULL got " ) ;
SCLogDebug ( " expected NULL got " ) ;
PrintRawUriFp ( stdout , cd - > content , cd - > content_len ) ;
PrintRawUriFp ( stdout , cd - > content , cd - > content_len ) ;
@ -545,6 +578,7 @@ int DetectContentParseTest05 (void)
result = 0 ;
result = 0 ;
DetectContentFree ( cd ) ;
DetectContentFree ( cd ) ;
}
}
SpmDestroyGlobalThreadCtx ( spm_global_thread_ctx ) ;
return result ;
return result ;
}
}
@ -558,7 +592,11 @@ int DetectContentParseTest06 (void)
char * teststring = " \" a|42|c|44|e|46| \" " ;
char * teststring = " \" a|42|c|44|e|46| \" " ;
char * teststringparsed = " abcdef " ;
char * teststringparsed = " abcdef " ;
cd = DetectContentParse ( teststring ) ;
uint16_t spm_matcher = SinglePatternMatchDefaultMatcher ( ) ;
SpmGlobalThreadCtx * spm_global_thread_ctx = SpmInitGlobalThreadCtx ( spm_matcher ) ;
FAIL_IF ( spm_global_thread_ctx = = NULL ) ;
cd = DetectContentParse ( spm_global_thread_ctx , teststring ) ;
if ( cd ! = NULL ) {
if ( cd ! = NULL ) {
uint16_t len = ( cd - > content_len > strlen ( teststringparsed ) ) ;
uint16_t len = ( cd - > content_len > strlen ( teststringparsed ) ) ;
if ( memcmp ( cd - > content , teststringparsed , len ) ! = 0 ) {
if ( memcmp ( cd - > content , teststringparsed , len ) ! = 0 ) {
@ -572,6 +610,7 @@ int DetectContentParseTest06 (void)
SCLogDebug ( " expected %s got NULL: " , teststringparsed ) ;
SCLogDebug ( " expected %s got NULL: " , teststringparsed ) ;
result = 0 ;
result = 0 ;
}
}
SpmDestroyGlobalThreadCtx ( spm_global_thread_ctx ) ;
return result ;
return result ;
}
}
@ -584,12 +623,17 @@ int DetectContentParseTest07 (void)
DetectContentData * cd = NULL ;
DetectContentData * cd = NULL ;
char * teststring = " \" \" " ;
char * teststring = " \" \" " ;
cd = DetectContentParse ( teststring ) ;
uint16_t spm_matcher = SinglePatternMatchDefaultMatcher ( ) ;
SpmGlobalThreadCtx * spm_global_thread_ctx = SpmInitGlobalThreadCtx ( spm_matcher ) ;
FAIL_IF ( spm_global_thread_ctx = = NULL ) ;
cd = DetectContentParse ( spm_global_thread_ctx , teststring ) ;
if ( cd ! = NULL ) {
if ( cd ! = NULL ) {
SCLogDebug ( " expected NULL got %p: " , cd ) ;
SCLogDebug ( " expected NULL got %p: " , cd ) ;
result = 0 ;
result = 0 ;
DetectContentFree ( cd ) ;
DetectContentFree ( cd ) ;
}
}
SpmDestroyGlobalThreadCtx ( spm_global_thread_ctx ) ;
return result ;
return result ;
}
}
@ -602,12 +646,17 @@ int DetectContentParseTest08 (void)
DetectContentData * cd = NULL ;
DetectContentData * cd = NULL ;
char * teststring = " \" \" " ;
char * teststring = " \" \" " ;
cd = DetectContentParse ( teststring ) ;
uint16_t spm_matcher = SinglePatternMatchDefaultMatcher ( ) ;
SpmGlobalThreadCtx * spm_global_thread_ctx = SpmInitGlobalThreadCtx ( spm_matcher ) ;
FAIL_IF ( spm_global_thread_ctx = = NULL ) ;
cd = DetectContentParse ( spm_global_thread_ctx , teststring ) ;
if ( cd ! = NULL ) {
if ( cd ! = NULL ) {
SCLogDebug ( " expected NULL got %p: " , cd ) ;
SCLogDebug ( " expected NULL got %p: " , cd ) ;
result = 0 ;
result = 0 ;
DetectContentFree ( cd ) ;
DetectContentFree ( cd ) ;
}
}
SpmDestroyGlobalThreadCtx ( spm_global_thread_ctx ) ;
return result ;
return result ;
}
}
@ -887,14 +936,18 @@ int DetectContentParseTest09(void)
DetectContentData * cd = NULL ;
DetectContentData * cd = NULL ;
char * teststring = " ! \" boo \" " ;
char * teststring = " ! \" boo \" " ;
cd = DetectContentParse ( teststring ) ;
uint16_t spm_matcher = SinglePatternMatchDefaultMatcher ( ) ;
SpmGlobalThreadCtx * spm_global_thread_ctx = SpmInitGlobalThreadCtx ( spm_matcher ) ;
FAIL_IF ( spm_global_thread_ctx = = NULL ) ;
cd = DetectContentParse ( spm_global_thread_ctx , teststring ) ;
if ( cd ! = NULL ) {
if ( cd ! = NULL ) {
if ( cd - > flags & DETECT_CONTENT_NEGATED )
if ( cd - > flags & DETECT_CONTENT_NEGATED )
result = 1 ;
result = 1 ;
DetectContentFree ( cd ) ;
DetectContentFree ( cd ) ;
}
}
SpmDestroyGlobalThreadCtx ( spm_global_thread_ctx ) ;
return result ;
return result ;
}
}
@ -904,13 +957,18 @@ int DetectContentParseTest10(void)
DetectContentData * cd = NULL ;
DetectContentData * cd = NULL ;
char * teststring = " ! \" boo \" " ;
char * teststring = " ! \" boo \" " ;
cd = DetectContentParse ( teststring ) ;
uint16_t spm_matcher = SinglePatternMatchDefaultMatcher ( ) ;
SpmGlobalThreadCtx * spm_global_thread_ctx = SpmInitGlobalThreadCtx ( spm_matcher ) ;
FAIL_IF ( spm_global_thread_ctx = = NULL ) ;
cd = DetectContentParse ( spm_global_thread_ctx , teststring ) ;
if ( cd ! = NULL ) {
if ( cd ! = NULL ) {
if ( cd - > flags & DETECT_CONTENT_NEGATED )
if ( cd - > flags & DETECT_CONTENT_NEGATED )
result = 1 ;
result = 1 ;
DetectContentFree ( cd ) ;
DetectContentFree ( cd ) ;
}
}
SpmDestroyGlobalThreadCtx ( spm_global_thread_ctx ) ;
return result ;
return result ;
}
}
@ -920,13 +978,18 @@ int DetectContentParseNegTest11(void)
DetectContentData * cd = NULL ;
DetectContentData * cd = NULL ;
char * teststring = " \" boo \" " ;
char * teststring = " \" boo \" " ;
cd = DetectContentParse ( teststring ) ;
uint16_t spm_matcher = SinglePatternMatchDefaultMatcher ( ) ;
SpmGlobalThreadCtx * spm_global_thread_ctx = SpmInitGlobalThreadCtx ( spm_matcher ) ;
FAIL_IF ( spm_global_thread_ctx = = NULL ) ;
cd = DetectContentParse ( spm_global_thread_ctx , teststring ) ;
if ( cd ! = NULL ) {
if ( cd ! = NULL ) {
if ( ! ( cd - > flags & DETECT_CONTENT_NEGATED ) )
if ( ! ( cd - > flags & DETECT_CONTENT_NEGATED ) )
result = 1 ;
result = 1 ;
DetectContentFree ( cd ) ;
DetectContentFree ( cd ) ;
}
}
SpmDestroyGlobalThreadCtx ( spm_global_thread_ctx ) ;
return result ;
return result ;
}
}
@ -936,13 +999,18 @@ int DetectContentParseNegTest12(void)
DetectContentData * cd = NULL ;
DetectContentData * cd = NULL ;
char * teststring = " \" boo \" " ;
char * teststring = " \" boo \" " ;
cd = DetectContentParse ( teststring ) ;
uint16_t spm_matcher = SinglePatternMatchDefaultMatcher ( ) ;
SpmGlobalThreadCtx * spm_global_thread_ctx = SpmInitGlobalThreadCtx ( spm_matcher ) ;
FAIL_IF ( spm_global_thread_ctx = = NULL ) ;
cd = DetectContentParse ( spm_global_thread_ctx , teststring ) ;
if ( cd ! = NULL ) {
if ( cd ! = NULL ) {
if ( ! ( cd - > flags & DETECT_CONTENT_NEGATED ) )
if ( ! ( cd - > flags & DETECT_CONTENT_NEGATED ) )
result = 1 ;
result = 1 ;
DetectContentFree ( cd ) ;
DetectContentFree ( cd ) ;
}
}
SpmDestroyGlobalThreadCtx ( spm_global_thread_ctx ) ;
return result ;
return result ;
}
}
@ -952,13 +1020,18 @@ int DetectContentParseNegTest13(void)
DetectContentData * cd = NULL ;
DetectContentData * cd = NULL ;
char * teststring = " ! \" boo \" " ;
char * teststring = " ! \" boo \" " ;
cd = DetectContentParse ( teststring ) ;
uint16_t spm_matcher = SinglePatternMatchDefaultMatcher ( ) ;
SpmGlobalThreadCtx * spm_global_thread_ctx = SpmInitGlobalThreadCtx ( spm_matcher ) ;
FAIL_IF ( spm_global_thread_ctx = = NULL ) ;
cd = DetectContentParse ( spm_global_thread_ctx , teststring ) ;
if ( cd ! = NULL ) {
if ( cd ! = NULL ) {
if ( cd - > flags & DETECT_CONTENT_NEGATED )
if ( cd - > flags & DETECT_CONTENT_NEGATED )
result = 1 ;
result = 1 ;
DetectContentFree ( cd ) ;
DetectContentFree ( cd ) ;
}
}
SpmDestroyGlobalThreadCtx ( spm_global_thread_ctx ) ;
return result ;
return result ;
}
}
@ -968,13 +1041,18 @@ int DetectContentParseNegTest14(void)
DetectContentData * cd = NULL ;
DetectContentData * cd = NULL ;
char * teststring = " \" !boo \" " ;
char * teststring = " \" !boo \" " ;
cd = DetectContentParse ( teststring ) ;
uint16_t spm_matcher = SinglePatternMatchDefaultMatcher ( ) ;
SpmGlobalThreadCtx * spm_global_thread_ctx = SpmInitGlobalThreadCtx ( spm_matcher ) ;
FAIL_IF ( spm_global_thread_ctx = = NULL ) ;
cd = DetectContentParse ( spm_global_thread_ctx , teststring ) ;
if ( cd ! = NULL ) {
if ( cd ! = NULL ) {
if ( ! ( cd - > flags & DETECT_CONTENT_NEGATED ) )
if ( ! ( cd - > flags & DETECT_CONTENT_NEGATED ) )
result = 1 ;
result = 1 ;
DetectContentFree ( cd ) ;
DetectContentFree ( cd ) ;
}
}
SpmDestroyGlobalThreadCtx ( spm_global_thread_ctx ) ;
return result ;
return result ;
}
}
@ -984,13 +1062,18 @@ int DetectContentParseNegTest15(void)
DetectContentData * cd = NULL ;
DetectContentData * cd = NULL ;
char * teststring = " ! \" boo \" " ;
char * teststring = " ! \" boo \" " ;
cd = DetectContentParse ( teststring ) ;
uint16_t spm_matcher = SinglePatternMatchDefaultMatcher ( ) ;
SpmGlobalThreadCtx * spm_global_thread_ctx = SpmInitGlobalThreadCtx ( spm_matcher ) ;
FAIL_IF ( spm_global_thread_ctx = = NULL ) ;
cd = DetectContentParse ( spm_global_thread_ctx , teststring ) ;
if ( cd ! = NULL ) {
if ( cd ! = NULL ) {
if ( cd - > flags & DETECT_CONTENT_NEGATED )
if ( cd - > flags & DETECT_CONTENT_NEGATED )
result = 1 ;
result = 1 ;
DetectContentFree ( cd ) ;
DetectContentFree ( cd ) ;
}
}
SpmDestroyGlobalThreadCtx ( spm_global_thread_ctx ) ;
return result ;
return result ;
}
}
@ -1000,11 +1083,16 @@ int DetectContentParseNegTest16(void)
DetectContentData * cd = NULL ;
DetectContentData * cd = NULL ;
char * teststring = " \" boo \" " ;
char * teststring = " \" boo \" " ;
cd = DetectContentParse ( teststring ) ;
uint16_t spm_matcher = SinglePatternMatchDefaultMatcher ( ) ;
SpmGlobalThreadCtx * spm_global_thread_ctx = SpmInitGlobalThreadCtx ( spm_matcher ) ;
FAIL_IF ( spm_global_thread_ctx = = NULL ) ;
cd = DetectContentParse ( spm_global_thread_ctx , teststring ) ;
if ( cd ! = NULL ) {
if ( cd ! = NULL ) {
result = ( cd - > content_len = = 3 & & memcmp ( cd - > content , " boo " , 3 ) = = 0 ) ;
result = ( cd - > content_len = = 3 & & memcmp ( cd - > content , " boo " , 3 ) = = 0 ) ;
DetectContentFree ( cd ) ;
DetectContentFree ( cd ) ;
}
}
SpmDestroyGlobalThreadCtx ( spm_global_thread_ctx ) ;
return result ;
return result ;
}
}
@ -2095,12 +2183,17 @@ int DetectContentParseTest41(void)
teststring [ idx + + ] = ' \" ' ;
teststring [ idx + + ] = ' \" ' ;
teststring [ idx + + ] = ' \0 ' ;
teststring [ idx + + ] = ' \0 ' ;
cd = DetectContentParse ( teststring ) ;
uint16_t spm_matcher = SinglePatternMatchDefaultMatcher ( ) ;
SpmGlobalThreadCtx * spm_global_thread_ctx = SpmInitGlobalThreadCtx ( spm_matcher ) ;
FAIL_IF ( spm_global_thread_ctx = = NULL ) ;
cd = DetectContentParse ( spm_global_thread_ctx , teststring ) ;
if ( cd = = NULL ) {
if ( cd = = NULL ) {
SCLogDebug ( " expected not NULL " ) ;
SCLogDebug ( " expected not NULL " ) ;
result = 0 ;
result = 0 ;
}
}
SpmDestroyGlobalThreadCtx ( spm_global_thread_ctx ) ;
SCFree ( teststring ) ;
SCFree ( teststring ) ;
DetectContentFree ( cd ) ;
DetectContentFree ( cd ) ;
return result ;
return result ;
@ -2125,12 +2218,17 @@ int DetectContentParseTest42(void)
teststring [ idx + + ] = ' \" ' ;
teststring [ idx + + ] = ' \" ' ;
teststring [ idx + + ] = ' \0 ' ;
teststring [ idx + + ] = ' \0 ' ;
cd = DetectContentParse ( teststring ) ;
uint16_t spm_matcher = SinglePatternMatchDefaultMatcher ( ) ;
SpmGlobalThreadCtx * spm_global_thread_ctx = SpmInitGlobalThreadCtx ( spm_matcher ) ;
FAIL_IF ( spm_global_thread_ctx = = NULL ) ;
cd = DetectContentParse ( spm_global_thread_ctx , teststring ) ;
if ( cd = = NULL ) {
if ( cd = = NULL ) {
SCLogDebug ( " expected not NULL " ) ;
SCLogDebug ( " expected not NULL " ) ;
result = 0 ;
result = 0 ;
}
}
SpmDestroyGlobalThreadCtx ( spm_global_thread_ctx ) ;
SCFree ( teststring ) ;
SCFree ( teststring ) ;
DetectContentFree ( cd ) ;
DetectContentFree ( cd ) ;
return result ;
return result ;
@ -2156,12 +2254,17 @@ int DetectContentParseTest43(void)
teststring [ idx + + ] = ' \" ' ;
teststring [ idx + + ] = ' \" ' ;
teststring [ idx + + ] = ' \0 ' ;
teststring [ idx + + ] = ' \0 ' ;
cd = DetectContentParse ( teststring ) ;
uint16_t spm_matcher = SinglePatternMatchDefaultMatcher ( ) ;
SpmGlobalThreadCtx * spm_global_thread_ctx = SpmInitGlobalThreadCtx ( spm_matcher ) ;
FAIL_IF ( spm_global_thread_ctx = = NULL ) ;
cd = DetectContentParse ( spm_global_thread_ctx , teststring ) ;
if ( cd = = NULL ) {
if ( cd = = NULL ) {
SCLogDebug ( " expected not NULL " ) ;
SCLogDebug ( " expected not NULL " ) ;
result = 0 ;
result = 0 ;
}
}
SpmDestroyGlobalThreadCtx ( spm_global_thread_ctx ) ;
SCFree ( teststring ) ;
SCFree ( teststring ) ;
DetectContentFree ( cd ) ;
DetectContentFree ( cd ) ;
return result ;
return result ;
@ -2190,12 +2293,17 @@ int DetectContentParseTest44(void)
teststring [ idx + + ] = ' \" ' ;
teststring [ idx + + ] = ' \" ' ;
teststring [ idx + + ] = ' \0 ' ;
teststring [ idx + + ] = ' \0 ' ;
cd = DetectContentParse ( teststring ) ;
uint16_t spm_matcher = SinglePatternMatchDefaultMatcher ( ) ;
SpmGlobalThreadCtx * spm_global_thread_ctx = SpmInitGlobalThreadCtx ( spm_matcher ) ;
FAIL_IF ( spm_global_thread_ctx = = NULL ) ;
cd = DetectContentParse ( spm_global_thread_ctx , teststring ) ;
if ( cd = = NULL ) {
if ( cd = = NULL ) {
SCLogDebug ( " expected not NULL " ) ;
SCLogDebug ( " expected not NULL " ) ;
result = 0 ;
result = 0 ;
}
}
SpmDestroyGlobalThreadCtx ( spm_global_thread_ctx ) ;
SCFree ( teststring ) ;
SCFree ( teststring ) ;
DetectContentFree ( cd ) ;
DetectContentFree ( cd ) ;
return result ;
return result ;