From: Victor Julien Date: Mon, 12 Dec 2016 11:20:46 +0000 (+0100) Subject: detect: cleanup built-in list id's X-Git-Tag: suricata-4.0.0-beta1~373 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=49fbd28ceb4299d5baa26f9423df95bc94fe5a71;p=thirdparty%2Fsuricata.git detect: cleanup built-in list id's --- diff --git a/src/detect-engine.c b/src/detect-engine.c index b0941fe842..8fc6fb766c 100644 --- a/src/detect-engine.c +++ b/src/detect-engine.c @@ -161,7 +161,7 @@ int DetectEngineAppInspectionEngine2Signature(Signature *s) /* convert lists to SigMatchData arrays */ int i = 0; - for (i = DETECT_SM_LIST_BUILTIN_MAX; i < nlists; i++) { + for (i = DETECT_SM_LIST_DYNAMIC_START; i < nlists; i++) { if (s->init_data->smlists[i] == NULL) continue; @@ -267,7 +267,7 @@ void DetectEngineAppInspectionEngineSignatureFree(Signature *s) #include "util-hash-lookup3.h" static HashListTable *g_buffer_type_hash = NULL; -static int g_buffer_type_id = DETECT_SM_LIST_MAX; // past DETECT_SM_LIST_NOTSET +static int g_buffer_type_id = DETECT_SM_LIST_DYNAMIC_START; static int g_buffer_type_reg_closed = 0; typedef struct DetectBufferType_ { @@ -515,6 +515,7 @@ void DetectBufferTypeFinalizeRegistration(void) g_buffer_type_map = SCCalloc(size, sizeof(DetectBufferType *)); BUG_ON(!g_buffer_type_map); + SCLogDebug("DETECT_SM_LIST_DYNAMIC_START %u", DETECT_SM_LIST_DYNAMIC_START); HashListTableBucket *b = HashListTableGetListHead(g_buffer_type_hash); while (b) { DetectBufferType *map = HashListTableGetListData(b); @@ -2816,11 +2817,8 @@ const char *DetectSigmatchListEnumToString(enum DetectSigmatchListEnum type) case DETECT_SM_LIST_THRESHOLD: return "threshold"; - case DETECT_SM_LIST_BUILTIN_MAX: case DETECT_SM_LIST_MAX: return "max (internal)"; - case DETECT_SM_LIST_NOTSET: - return "not set (internal)"; } return "error"; } diff --git a/src/detect-parse.c b/src/detect-parse.c index 5f59ba6b14..64aaff96e5 100644 --- a/src/detect-parse.c +++ b/src/detect-parse.c @@ -148,7 +148,6 @@ const char *DetectListToHumanString(int list) CASE_CODE_STRING(DETECT_SM_LIST_SUPPRESS, "suppress"); CASE_CODE_STRING(DETECT_SM_LIST_THRESHOLD, "threshold"); CASE_CODE_STRING(DETECT_SM_LIST_MAX, "max (internal)"); - CASE_CODE_STRING(DETECT_SM_LIST_NOTSET, "not set (internal)"); } #undef CASE_CODE_STRING return "unknown"; @@ -167,7 +166,6 @@ const char *DetectListToString(int list) CASE_CODE(DETECT_SM_LIST_SUPPRESS); CASE_CODE(DETECT_SM_LIST_THRESHOLD); CASE_CODE(DETECT_SM_LIST_MAX); - CASE_CODE(DETECT_SM_LIST_NOTSET); } return "unknown"; } @@ -1117,7 +1115,7 @@ static void SigMatchFreeArrays(Signature *s, int ctxs) { if (s != NULL) { int type; - for (type = 0; type < DETECT_SM_LIST_BUILTIN_MAX; type++) { + for (type = 0; type < DETECT_SM_LIST_MAX; type++) { if (s->sm_arrays[type] != NULL) { if (ctxs) { SigMatchData *smd = s->sm_arrays[type]; diff --git a/src/detect.c b/src/detect.c index 62de800c0a..cb21cbf9e3 100644 --- a/src/detect.c +++ b/src/detect.c @@ -3780,8 +3780,9 @@ static int SigMatchPrepare(DetectEngineCtx *de_ctx) /* set up inspect engines */ DetectEngineAppInspectionEngine2Signature(s); + /* built-ins */ int type; - for (type = 0; type < DETECT_SM_LIST_BUILTIN_MAX; type++) { + for (type = 0; type < DETECT_SM_LIST_MAX; type++) { SigMatch *sm = s->init_data->smlists[type]; s->sm_arrays[type] = SigMatchList2DataArray(sm); } diff --git a/src/detect.h b/src/detect.h index e7f6a5765d..8b752e4b03 100644 --- a/src/detect.h +++ b/src/detect.h @@ -108,17 +108,17 @@ enum DetectSigmatchListEnum { DETECT_SM_LIST_SUPPRESS, DETECT_SM_LIST_THRESHOLD, - /* used for Signature->list, which indicates which list - * we're adding keywords to in cases of sticky buffers like - * file_data */ - DETECT_SM_LIST_NOTSET, - - DETECT_SM_LIST_BUILTIN_MAX, - DETECT_SM_LIST_MAX, + /* start of dynamically registered lists */ + DETECT_SM_LIST_DYNAMIC_START = DETECT_SM_LIST_MAX, }; +/* used for Signature->list, which indicates which list + * we're adding keywords to in cases of sticky buffers like + * file_data */ +#define DETECT_SM_LIST_NOTSET INT_MAX + /* a is ... than b */ enum { ADDRESS_ER = -1, /**< error e.g. compare ipv4 and ipv6 */ @@ -446,7 +446,7 @@ typedef struct Signature_ { /* Matching structures for the built-ins. The others are in * their inspect engines. */ - SigMatchData *sm_arrays[DETECT_SM_LIST_BUILTIN_MAX]; + SigMatchData *sm_arrays[DETECT_SM_LIST_MAX]; /* memory is still owned by the sm_lists/sm_arrays entry */ const struct DetectFilestoreData_ *filestore_ctx;