detect/datarep: fix format truncation warning

detect-datarep.c: In function ‘SetupLoadPath’:
detect-datarep.c:262: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=]
  262 |     if (snprintf(path, sizeof(path), "%s/%s", dir, load) >= (int)sizeof(path)) // TODO windows path
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
detect-datarep.c:262:9: note: assuming directive output of 1 byte
detect-datarep.c:262:9: note: ‘snprintf’ output 2 or more bytes (assuming 4098) into a destination of size 4096
cc1: all warnings being treated as errors

Ticket: #7905.
pull/13926/head
Victor Julien 10 months ago committed by Victor Julien
parent 8630b29611
commit 14987dca35

@ -259,7 +259,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)) {

Loading…
Cancel
Save