From: Andreas Herz Date: Wed, 11 Jun 2025 08:47:45 +0000 (+0200) Subject: detect/dataset: skip adding localstatedir if fullpath is provided X-Git-Tag: suricata-8.0.0-rc1~1 X-Git-Url: http://git.ipfire.org/gitweb/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F13437%2Fhead;p=thirdparty%2Fsuricata.git 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 --- 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; }