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 Feb 4, 2024
1 parent 13625cf commit 11262a9
Showing 1 changed file with 3 additions and 15 deletions.
18 changes: 3 additions & 15 deletions src/detect-engine-loader.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 11262a9

Please sign in to comment.