From 8630b29611b1a64d50b42c2c4df05e51aedd1cac Mon Sep 17 00:00:00 2001 From: Victor Julien Date: Wed, 24 Sep 2025 07:56:15 +0200 Subject: [PATCH] util/pidfile: address format truncation warning MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- src/util-pidfile.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/util-pidfile.c b/src/util-pidfile.c index 1cbae0eb7a..201ad1c9f5 100644 --- a/src/util-pidfile.c +++ b/src/util-pidfile.c @@ -44,7 +44,7 @@ int SCPidfileCreate(const char *pidfile) SCEnter(); int pidfd = 0; - char val[16]; + char val[32]; size_t len = snprintf(val, sizeof(val), "%"PRIuMAX"\n", (uintmax_t)getpid()); if (len <= 0) {