From 7759d06851c2b0199bdac065f6ec67af33126c5e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rodolfo=20Garc=C3=ADa=20Pe=C3=B1as=20=28kix=29?= Date: Wed, 19 Jun 2019 21:11:04 +0200 Subject: [PATCH] wmgenmenu.c Removed format-truncation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This patch removes the format-truncation warning. The problem is because buf and comm are arrays with the same size (PATH_MAX). In the snprintf, comm is copied to buf, more some extra characters. The patch reduces the size for the array comm in the extra characters. Without the patch, the comm array is truncated. With the patch, the same characters are copied, without the warning. wmgenmenu.c: In function ‘find_and_write’: wmgenmenu.c:436:41: warning: ‘snprintf’ output may be truncated before the last format character [-Wformat-truncation=] snprintf(buf, sizeof(buf), "%s -e %s", terminal ? terminal : "xterm" , comm); ^ wmgenmenu.c:436:5: note: ‘snprintf’ output 5 or more bytes (assuming 4105) into a destination of size 4104 snprintf(buf, sizeof(buf), "%s -e %s", terminal ? terminal : "xterm" , comm); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Signed-off-by: Rodolfo García Peñas (kix) --- util/wmgenmenu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/util/wmgenmenu.c b/util/wmgenmenu.c index e7599ce4..7764d0fb 100644 --- a/util/wmgenmenu.c +++ b/util/wmgenmenu.c @@ -418,7 +418,7 @@ static void find_and_write(const char *group, char *list[][2], int this_is_termi NULL ); } else { - char comm[PATH_MAX], *ptr; + char comm[PATH_MAX - 9], *ptr; strncpy(comm, list[i][1], sizeof(comm) - 1); comm[sizeof(comm) - 1] = '\0';