From 173132b05b95aa584f7c6a237b53d0efa2b76b53 Mon Sep 17 00:00:00 2001 From: Andreas Herz Date: Wed, 11 Jun 2025 10:47:45 +0200 Subject: [PATCH] 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 --- src/detect-dataset.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/detect-dataset.c b/src/detect-dataset.c index 54e3be28c7..a6c2317aef 100644 --- a/src/detect-dataset.c +++ b/src/detect-dataset.c @@ -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; } -- 2.47.2