]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
detect: debug validation for list ids overflows
authorPhilippe Antoine <contact@catenacyber.fr>
Mon, 30 Aug 2021 20:01:18 +0000 (22:01 +0200)
committerVictor Julien <victor@inliniac.net>
Wed, 1 Sep 2021 06:33:52 +0000 (08:33 +0200)
src/detect-engine-mpm.c

index 96bb001151401246e74e9119bac3da525b8b7459..702ad734f0629fa49c285836e5f967f5b6ee92bb 100644 (file)
@@ -115,6 +115,7 @@ void DetectAppLayerMpmRegister2(const char *name,
     am->name = name;
     snprintf(am->pname, sizeof(am->pname), "%s", am->name);
     am->direction = direction;
+    DEBUG_VALIDATE_BUG_ON(sm_list < 0 || sm_list > INT16_MAX);
     am->sm_list = sm_list;
     am->sm_list_base = sm_list;
     am->priority = priority;
@@ -155,6 +156,7 @@ void DetectAppLayerMpmRegisterByParentId(DetectEngineCtx *de_ctx,
             BUG_ON(am == NULL);
             am->name = t->name;
             am->direction = t->direction;
+            DEBUG_VALIDATE_BUG_ON(id < 0 || id > INT16_MAX);
             am->sm_list = id; // use new id
             am->sm_list_base = t->sm_list;
             am->type = DETECT_BUFFER_MPM_TYPE_APP;
@@ -314,6 +316,7 @@ void DetectPktMpmRegister(const char *name,
     BUG_ON(am == NULL);
     am->name = name;
     snprintf(am->pname, sizeof(am->pname), "%s", am->name);
+    DEBUG_VALIDATE_BUG_ON(sm_list < 0 || sm_list > INT16_MAX);
     am->sm_list = sm_list;
     am->priority = priority;
     am->type = DETECT_BUFFER_MPM_TYPE_PKT;
@@ -351,6 +354,7 @@ void DetectPktMpmRegisterByParentId(DetectEngineCtx *de_ctx,
             BUG_ON(am == NULL);
             am->name = t->name;
             snprintf(am->pname, sizeof(am->pname), "%s#%d", am->name, id);
+            DEBUG_VALIDATE_BUG_ON(id < 0 || id > INT16_MAX);
             am->sm_list = id; // use new id
             am->sm_list_base = t->sm_list;
             am->type = DETECT_BUFFER_MPM_TYPE_PKT;