1
0
mirror of https://github.com/gryf/wmaker.git synced 2025-12-18 20:10:29 +01:00

wmgenmenu.c Removed format-truncation

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) <kix@kix.es>
This commit is contained in:
Rodolfo García Peñas (kix)
2019-06-19 21:11:04 +02:00
committed by Carlos R. Mafra
parent bf644338e4
commit 7759d06851

View File

@@ -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';