From f48099edd3d3dadc07c2e758f231063668409eb8 Mon Sep 17 00:00:00 2001 From: Victor Julien Date: Wed, 24 Sep 2025 08:14:12 +0200 Subject: [PATCH] detect/datasets: address format truncation warnings MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit detect-dataset.c: In function ‘SetupLoadPath’: detect-dataset.c:391:9: error: ‘%s’ directive output may be truncated writing likely 1 or more bytes into a region of size between 0 and 4095 [-Werror=format-truncation=] 391 | if (snprintf(path, sizeof(path), "%s/%s", dir, load) >= (int)sizeof(path)) // TODO windows path | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ detect-dataset.c:391:9: note: assuming directive output of 1 byte detect-dataset.c:391:9: note: ‘snprintf’ output 2 or more bytes (assuming 4098) into a destination of size 4096 Ticket: #7905. --- src/detect-dataset.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/detect-dataset.c b/src/detect-dataset.c index a6c2317aef..6e9abfc0f5 100644 --- a/src/detect-dataset.c +++ b/src/detect-dataset.c @@ -388,7 +388,7 @@ static int SetupLoadPath(const DetectEngineCtx *de_ctx, SCLogDebug("rule_file %s dir %s", de_ctx->rule_file, dir); char path[PATH_MAX]; - if (snprintf(path, sizeof(path), "%s/%s", dir, load) >= (int)sizeof(path)) // TODO windows path + if (PathMerge(path, sizeof(path), dir, load) < 0) return -1; if (SCPathExists(path)) { @@ -447,8 +447,7 @@ static int SetupSavePath(const DetectEngineCtx *de_ctx, BUG_ON(dir == NULL); // should not be able to fail if (!PathIsAbsolute(save)) { char path[PATH_MAX]; - if (snprintf(path, sizeof(path), "%s/%s", dir, save) >= - (int)sizeof(path)) // TODO windows path + if (PathMerge(path, sizeof(path), dir, save) < 0) return -1; /* TODO check if location exists and is writable */