detect/dataset: skip adding localstatedir if fullpath is provided

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
pull/13437/head
Andreas Herz 5 months ago committed by Victor Julien
parent 8f26b4a0ff
commit 173132b05b

@ -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;
}

Loading…
Cancel
Save