]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
added null checks for init_hash to all ac mpms
authorEileen Donlon <emdonlo@gmail.com>
Tue, 13 Mar 2012 19:31:13 +0000 (15:31 -0400)
committerVictor Julien <victor@inliniac.net>
Mon, 19 Mar 2012 09:46:27 +0000 (10:46 +0100)
src/util-mpm-ac-bs.c
src/util-mpm-ac-gfbs.c
src/util-mpm-ac.c

index 9e08a2344c0a722231a59388170b51f76bda2055..60608ab9fbd90318cb13fa0fadf2110e08a4fce1 100644 (file)
@@ -192,7 +192,7 @@ static inline SCACBSPattern *SCACBSInitHashLookup(SCACBSCtx *ctx, uint8_t *pat,
 {
     uint32_t hash = SCACBSInitHashRaw(pat, patlen);
 
-    if (ctx->init_hash[hash] == NULL) {
+    if (ctx->init_hash == NULL || ctx->init_hash[hash] == NULL) {
         return NULL;
     }
 
@@ -293,6 +293,10 @@ static inline int SCACBSInitHashAdd(SCACBSCtx *ctx, SCACBSPattern *p)
 {
     uint32_t hash = SCACBSInitHash(p);
 
+    if (ctx->init_hash == NULL) {
+        return 0;
+    }
+
     if (ctx->init_hash[hash] == NULL) {
         ctx->init_hash[hash] = p;
         return 0;
@@ -1162,7 +1166,7 @@ int SCACBSPreparePatterns(MpmCtx *mpm_ctx)
 {
     SCACBSCtx *ctx = (SCACBSCtx *)mpm_ctx->ctx;
 
-    if (mpm_ctx->pattern_cnt == 0) {
+    if (mpm_ctx->pattern_cnt == 0 || ctx->init_hash == NULL) {
         SCLogDebug("no patterns supplied to this mpm_ctx");
         return 0;
     }
index f26d7c82cc029cade2c7e790ccc53c2dfd241196..885a66c2e93163b98f8f2680290757c2c8c53346 100644 (file)
@@ -186,7 +186,7 @@ static inline SCACGfbsPattern *SCACGfbsInitHashLookup(SCACGfbsCtx *ctx, uint8_t
 {
     uint32_t hash = SCACGfbsInitHashRaw(pat, patlen);
 
-    if (ctx->init_hash[hash] == NULL) {
+    if (ctx->init_hash == NULL || ctx->init_hash[hash] == NULL) {
         return NULL;
     }
 
@@ -287,6 +287,10 @@ static inline int SCACGfbsInitHashAdd(SCACGfbsCtx *ctx, SCACGfbsPattern *p)
 {
     uint32_t hash = SCACGfbsInitHash(p);
 
+    if (ctx->init_hash == NULL) {
+        return 0;
+    }
+
     if (ctx->init_hash[hash] == NULL) {
         ctx->init_hash[hash] = p;
         return 0;
@@ -1036,7 +1040,7 @@ int SCACGfbsPreparePatterns(MpmCtx *mpm_ctx)
 {
     SCACGfbsCtx *ctx = (SCACGfbsCtx *)mpm_ctx->ctx;
 
-    if (mpm_ctx->pattern_cnt == 0) {
+    if (mpm_ctx->pattern_cnt == 0 || ctx->init_hash == NULL) {
         SCLogDebug("No patterns supplied to this mpm_ctx");
         return 0;
     }
index e64aff95d088e5519dc33b58b7280a07229845cb..dc520f11248609617262d7b3b0e518fe92c14d10 100644 (file)
@@ -192,7 +192,7 @@ static inline SCACPattern *SCACInitHashLookup(SCACCtx *ctx, uint8_t *pat,
 {
     uint32_t hash = SCACInitHashRaw(pat, patlen);
 
-    if (ctx->init_hash[hash] == NULL) {
+    if (ctx->init_hash == NULL || ctx->init_hash[hash] == NULL) {
         return NULL;
     }
 
@@ -293,6 +293,10 @@ static inline int SCACInitHashAdd(SCACCtx *ctx, SCACPattern *p)
 {
     uint32_t hash = SCACInitHash(p);
 
+    if (ctx->init_hash == NULL) {
+        return 0;
+    }
+
     if (ctx->init_hash[hash] == NULL) {
         ctx->init_hash[hash] = p;
         return 0;
@@ -953,7 +957,7 @@ int SCACPreparePatterns(MpmCtx *mpm_ctx)
 {
     SCACCtx *ctx = (SCACCtx *)mpm_ctx->ctx;
 
-    if (mpm_ctx->pattern_cnt == 0) {
+    if (mpm_ctx->pattern_cnt == 0 || ctx->init_hash == NULL) {
         SCLogDebug("no patterns supplied to this mpm_ctx");
         return 0;
     }