]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
detect: allow for more than 64k mpm rules 1914/head
authorVictor Julien <victor@inliniac.net>
Tue, 8 Mar 2016 19:29:09 +0000 (20:29 +0100)
committerVictor Julien <victor@inliniac.net>
Wed, 9 Mar 2016 09:12:17 +0000 (10:12 +0100)
src/detect-content.h
src/detect-engine-mpm.c
src/detect.h
src/suricata-common.h
src/util-mpm-ac-bs.c
src/util-mpm-ac-bs.h
src/util-mpm-ac-gfbs.c
src/util-mpm-ac-gfbs.h
src/util-mpm-ac.c
src/util-mpm-ac.h

index b2e0f9694f573486673aa3c16cfe85be5ea5f145..00c1ea3920d8b233efac97c8a3be16655cb3a07f 100644 (file)
@@ -69,6 +69,8 @@ typedef struct DetectContentData_ {
     uint16_t replace_len;
     /* for chopped fast pattern, the length */
     uint16_t fp_chop_len;
+    /* for chopped fast pattern, the offset */
+    uint16_t fp_chop_offset;
     /* would want to move PatIntId here and flags down to remove the padding
      * gap, but I think the first four members was used as a template for
      * casting.  \todo check this and fix it if posssible */
@@ -76,8 +78,6 @@ typedef struct DetectContentData_ {
     PatIntId id;
     uint16_t depth;
     uint16_t offset;
-    /* for chopped fast pattern, the offset */
-    uint16_t fp_chop_offset;
     int32_t distance;
     int32_t within;
     /* Boyer Moore context (for spm search) */
index 7fd532e5cc0e4c757c4fc5de09b19c7bb159c46c..5a21823ce845b30e7ed24b227e5d64178fb3d172 100644 (file)
@@ -1064,14 +1064,14 @@ void PatternMatchDestroyGroup(SigGroupHead *sh)
  *         always used, etc. */
 typedef struct ContentHash_ {
     DetectContentData *ptr;
-    uint16_t cnt;
-    uint8_t use; /* use no matter what */
+    uint32_t cnt;
+    int use; /* use no matter what */
 } ContentHash;
 
 typedef struct UricontentHash_ {
     DetectContentData *ptr;
-    uint16_t cnt;
-    uint8_t use; /* use no matter what */
+    uint32_t cnt;
+    int use; /* use no matter what */
 } UricontentHash;
 
 uint32_t ContentHashFunc(HashTable *ht, void *data, uint16_t datalen)
@@ -2714,8 +2714,8 @@ typedef struct MpmPatternIdTableElmt_ {
     uint8_t *pattern;       /**< ptr to the pattern */
     uint16_t pattern_len;   /**< pattern len */
     PatIntId id;            /**< pattern id */
-    uint16_t dup_count;     /**< duplicate count */
-    uint8_t sm_list;        /**< SigMatch list */
+    uint32_t dup_count;     /**< duplicate count */
+    int sm_list;            /**< SigMatch list */
 } MpmPatternIdTableElmt;
 
 /** \brief Hash compare func for MpmPatternId api
index 89ce35ab1ca2112adfe5b4e48e1dc981edf61e69..c36b9ce1e955e0e52b0081f055187d8ba32ee6bb 100644 (file)
@@ -640,7 +640,7 @@ typedef struct DetectEngineCtx_ {
     /** hash table for looking up patterns for
      *  id sharing and id tracking. */
     MpmPatternIdStore *mpm_pattern_id_store;
-    uint16_t max_fp_id;
+    uint32_t max_fp_id;
 
     MpmCtxFactoryContainer *mpm_ctx_factory_container;
 
index 05bfcdf9ec3bc223cf3788c0b69f98de7cefd0ce..660a0bfecc3e8f4fadb520dfbba1e6f4dbeaa1c5 100644 (file)
 #define SigIntId uint32_t
 
 /** same for pattern id's */
-#define PatIntId uint16_t
+#define PatIntId uint32_t
 
 /** FreeBSD does not define __WORDSIZE, but it uses __LONG_BIT */
 #ifndef __WORDSIZE
index d6c4e78502cdb661a5fe430db7436ef8ddae0c10..f19acbcd4a5374c7381ee76fb26701dd4050798b 100644 (file)
@@ -1382,7 +1382,7 @@ void SCACBSDestroyCtx(MpmCtx *mpm_ctx)
     }
 
     if (ctx->pid_pat_list != NULL) {
-        int i;
+        uint32_t i;
         for (i = 0; i < (ctx->max_pat_id + 1); i++) {
             if (ctx->pid_pat_list[i].cs != NULL)
                 SCFree(ctx->pid_pat_list[i].cs);
index a66757e72a3da047be6182409fb55c5942920d01..ce9c59fc5c2837f435fdd5472eebe020c836d68a 100644 (file)
@@ -88,7 +88,7 @@ typedef struct SCACBSCtx_ {
 
     /* the size of each state */
     uint16_t single_state_size;
-    uint16_t max_pat_id;
+    uint32_t max_pat_id;
 } SCACBSCtx;
 
 typedef struct SCACBSThreadCtx_ {
index e0ace7f3e7f2f473cb58bee073e16ff80c7a95cd..bfff68890898dc0897651b858d213b63c25a40c7 100644 (file)
@@ -1259,7 +1259,7 @@ void SCACGfbsDestroyCtx(MpmCtx *mpm_ctx)
     }
 
     if (ctx->pid_pat_list != NULL) {
-        int i;
+        uint32_t i;
         for (i = 0; i < (ctx->max_pat_id + 1); i++) {
             if (ctx->pid_pat_list[i].cs != NULL)
                 SCFree(ctx->pid_pat_list[i].cs);
index 4003a5b560a58669f42978716d329d37a5ae4d37..521c8db03530de635d67f2dd6bdffafaeb22fe1c 100644 (file)
@@ -97,7 +97,7 @@ typedef struct SCACGfbsCtx_ {
 
     /* the size of each state */
     uint16_t single_state_size;
-    uint16_t max_pat_id;
+    uint32_t max_pat_id;
 } SCACGfbsCtx;
 
 typedef struct SCACGfbsThreadCtx_ {
index c8f6be77a205fc1ffff77688ecdb51ec096b8164..49df0d6ea92779336f11da2816c040c86f45a26c 100644 (file)
@@ -1273,7 +1273,7 @@ void SCACDestroyCtx(MpmCtx *mpm_ctx)
     }
 
     if (ctx->pid_pat_list != NULL) {
-        int i;
+        uint32_t i;
         for (i = 0; i < (ctx->max_pat_id + 1); i++) {
             if (ctx->pid_pat_list[i].cs != NULL)
                 SCFree(ctx->pid_pat_list[i].cs);
index a837f5f015415e10051dcce69ff7c7141105bef3..13bd16fbdcaecfed24e32b9581f8506678c80f7a 100644 (file)
@@ -97,8 +97,8 @@ typedef struct SCACCtx_ {
     SCACPatternList *pid_pat_list;
 
     /* the size of each state */
-    uint16_t single_state_size;
-    uint16_t max_pat_id;
+    uint32_t single_state_size;
+    uint32_t max_pat_id;
 
     uint32_t allocated_state_count;