From: Victor Julien Date: Thu, 10 Aug 2023 08:08:37 +0000 (+0200) Subject: detect: fix path creation in Windows X-Git-Tag: suricata-6.0.16~9 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=11262a94de021b41903aa29de0a9f655b1d13e0f;p=thirdparty%2Fsuricata.git detect: fix path creation in Windows Fixes file loading for rule files and Lua scripts. Bug: #6095. (cherry picked from commit 04aee5f0995c6ba08d35ee5e363c4e0b9f82b5ca) --- diff --git a/src/detect-engine-loader.c b/src/detect-engine-loader.c index 0e77a98905..99364a0a24 100644 --- a/src/detect-engine-loader.c +++ b/src/detect-engine-loader.c @@ -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;