Skip to content

Commit

Permalink
detect: fix path creation in Windows
Browse files Browse the repository at this point in the history
Fixes file loading for rule files and Lua scripts.

Bug: OISF#6095.
(cherry picked from commit 04aee5f)
  • Loading branch information
victorjulien authored and jlucovsky committed Aug 22, 2023
1 parent a28f21e commit f9bc6cb
Showing 1 changed file with 1 addition and 13 deletions.
14 changes: 1 addition & 13 deletions src/detect-engine-loader.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,21 +84,9 @@ char *DetectLoadCompleteSigPath(const DetectEngineCtx *de_ctx, const char *sig_f
/* Path not specified */
if (PathIsRelative(sig_file)) {
if (defaultpath) {
SCLogDebug("Default path: %s", defaultpath);
size_t path_len = sizeof(char) * (strlen(defaultpath) +
strlen(sig_file) + 2);
path = SCMalloc(path_len);
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 {
path = SCStrdup(sig_file);
if (unlikely(path == NULL))
Expand Down

0 comments on commit f9bc6cb

Please sign in to comment.