]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
detect/dataset: skip adding localstatedir if fullpath is provided 13437/head
authorAndreas Herz <andreas@stamus-networks.com>
Wed, 11 Jun 2025 08:47:45 +0000 (10:47 +0200)
committerVictor Julien <victor@inliniac.net>
Thu, 12 Jun 2025 10:53:58 +0000 (12:53 +0200)
When the option to set a full path is enabled and a full path is
provided, skip adding the prefix (based on localstatedir) to the
directory since it would be unexpected and unwanted by a user.

Ticket: 7083

src/detect-dataset.c

index 54e3be28c709fba16900e76816eb729913f6a046..a6c2317aefc0a9558a8750121940bd8842bf8b5a 100644 (file)
@@ -445,13 +445,16 @@ static int SetupSavePath(const DetectEngineCtx *de_ctx,
     // data dir
     const char *dir = ConfigGetDataDirectory();
     BUG_ON(dir == NULL); // should not be able to fail
-    char path[PATH_MAX];
-    if (snprintf(path, sizeof(path), "%s/%s", dir, save) >= (int)sizeof(path)) // TODO windows path
-        return -1;
+    if (!PathIsAbsolute(save)) {
+        char path[PATH_MAX];
+        if (snprintf(path, sizeof(path), "%s/%s", dir, save) >=
+                (int)sizeof(path)) // TODO windows path
+            return -1;
 
-    /* TODO check if location exists and is writable */
+        /* TODO check if location exists and is writable */
 
-    strlcpy(save, path, save_size);
+        strlcpy(save, path, save_size);
+    }
 
     return 0;
 }