]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
util/var: add NULL check in VarNameStoreRegister 14213/head
authorPhilippe Antoine <pantoine@oisf.net>
Wed, 29 Oct 2025 21:29:11 +0000 (22:29 +0100)
committerVictor Julien <vjulien@oisf.net>
Thu, 30 Oct 2025 16:16:35 +0000 (16:16 +0000)
And check return value in entropy keyword setup

(cherry picked from commit 854201703e51afd0945c5a9ec4d5b62303f9ca9d)

src/detect-entropy.c
src/util-var-name.c

index 4ef97b7e949b58e9559600669e2e98997c88e86f..fee8307a0ec18ce1354c4698f12afca3c02a5acc 100644 (file)
@@ -56,6 +56,9 @@ static int DetectEntropySetup(DetectEngineCtx *de_ctx, Signature *s, const char
     } else {
         ded->fv_idx = VarNameStoreRegister("content", VAR_TYPE_FLOW_FLOAT);
     }
+    if (ded->fv_idx == 0) {
+        goto error;
+    }
 
     if (SCSigMatchAppendSMToList(de_ctx, s, DETECT_ENTROPY, (SigMatchCtx *)ded, sm_list) != NULL) {
         SCReturnInt(0);
index b5b518d6b0f594bed3efc2914ab580b46614855f..a81920f3515a5518b84890a6eba28184d029a9b6 100644 (file)
@@ -154,6 +154,9 @@ void VarNameStoreDestroy(void)
  */
 uint32_t VarNameStoreRegister(const char *name, const enum VarTypes type)
 {
+    if (name == NULL) {
+        return 0;
+    }
     SCMutexLock(&base_lock);
     uint32_t id = 0;