]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
detect: fix path creation in Windows
authorVictor Julien <vjulien@oisf.net>
Thu, 10 Aug 2023 08:08:37 +0000 (10:08 +0200)
committerJeff Lucovsky <jlucovsky@oisf.net>
Sun, 4 Feb 2024 14:25:08 +0000 (09:25 -0500)
Fixes file loading for rule files and Lua scripts.

Bug: #6095.
(cherry picked from commit 04aee5f0995c6ba08d35ee5e363c4e0b9f82b5ca)

src/detect-engine-loader.c

index 0e77a98905293ff66d221787fd3049c6c606e0d9..99364a0a249ad78ccafde0ec44eb038872697297 100644 (file)
@@ -77,23 +77,11 @@ char *DetectLoadCompleteSigPath(const DetectEngineCtx *de_ctx, const char *sig_f
 
     /* Path not specified */
     if (PathIsRelative(sig_file)) {
-        if (ConfGet(varname, &defaultpath) == 1) {
-            SCLogDebug("Default path: %s", defaultpath);
-            size_t path_len = sizeof(char) * (strlen(defaultpath) +
-                          strlen(sig_file) + 2);
-            path = SCMalloc(path_len);
+        if (defaultpath) {
+            path = PathMergeAlloc(defaultpath, sig_file);
             if (unlikely(path == NULL))
                 return NULL;
-            strlcpy(path, defaultpath, path_len);
-#if defined OS_WIN32 || defined __CYGWIN__
-            if (path[strlen(path) - 1] != '\\')
-                strlcat(path, "\\\\", path_len);
-#else
-            if (path[strlen(path) - 1] != '/')
-                strlcat(path, "/", path_len);
-#endif
-            strlcat(path, sig_file, path_len);
-       } else {
+        } else {
             path = SCStrdup(sig_file);
             if (unlikely(path == NULL))
                 return NULL;