util/pidfile: address format truncation warning

util-pidfile.c: In function ‘SCPidfileCreate’:
util-pidfile.c:49:18: error: ‘%lu’ directive output may be truncated writing between 1 and 20 bytes into a region of size 16 [-Werror=format-truncation=]
   49 |     size_t len = snprintf(val, sizeof(val), "%"PRIuMAX"\n", (uintmax_t)getpid());
      |                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
util-pidfile.c:49:18: note: using the range [0, 18446744073709551615] for directive argument
util-pidfile.c:49:18: note: ‘snprintf’ output between 3 and 22 bytes into a destination of size 16
   49 |     size_t len = snprintf(val, sizeof(val), "%"PRIuMAX"\n", (uintmax_t)getpid());
      |                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors

Ticket: #7905.
pull/13926/head
Victor Julien 2 months ago committed by Victor Julien
parent 746823f3df
commit 8630b29611

@ -44,7 +44,7 @@ int SCPidfileCreate(const char *pidfile)
SCEnter(); SCEnter();
int pidfd = 0; int pidfd = 0;
char val[16]; char val[32];
size_t len = snprintf(val, sizeof(val), "%"PRIuMAX"\n", (uintmax_t)getpid()); size_t len = snprintf(val, sizeof(val), "%"PRIuMAX"\n", (uintmax_t)getpid());
if (len <= 0) { if (len <= 0) {

Loading…
Cancel
Save