Skip to content

Commit

Permalink
detect/dataset: skip adding localstatedir if fullpath is provided
Browse files Browse the repository at this point in the history
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
  • Loading branch information
norg committed Jun 10, 2024
1 parent d9d5170 commit 80c041a
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/detect-dataset.c
Original file line number Diff line number Diff line change
Expand Up @@ -330,12 +330,15 @@ static int SetupSavePath(const DetectEngineCtx *de_ctx,
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;

/* TODO check if location exists and is writable */
if (!PathIsAbsolute(save)) {
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 */

strlcpy(save, path, save_size);
strlcpy(save, path, save_size);
}

return 0;
}
Expand Down

0 comments on commit 80c041a

Please sign in to comment.