1
0
mirror of https://github.com/gryf/wmaker.git synced 2025-12-21 05:18:06 +01:00

util: fix possible buffer overrun in the function that create L2 menus (Coverity #50219)

As pointed by Coverity, the buffer used to store the command for the menu
has a fixed size, so a check is welcome to avoid buffer overflow.

Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
This commit is contained in:
Christophe CURIS
2014-06-16 20:15:26 +02:00
committed by Carlos R. Mafra
parent 7c142f54d0
commit 36ac3b3344

View File

@@ -419,7 +419,9 @@ static void find_and_write(const char *group, char *list[][2], int this_is_termi
} else { } else {
char comm[PATH_MAX], *ptr; char comm[PATH_MAX], *ptr;
strcpy(comm, list[i][1]); strncpy(comm, list[i][1], sizeof(comm) - 1);
comm[sizeof(comm) - 1] = '\0';
/* delete character " !" from the command */ /* delete character " !" from the command */
ptr = strchr(comm, '!'); ptr = strchr(comm, '!');
while (ptr >= comm && (*ptr == '!' || isspace(*ptr))) while (ptr >= comm && (*ptr == '!' || isspace(*ptr)))