From 36ac3b33447660418f3e602fab82fae088b26b54 Mon Sep 17 00:00:00 2001 From: Christophe CURIS Date: Mon, 16 Jun 2014 20:15:26 +0200 Subject: [PATCH] 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 --- util/wmgenmenu.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/util/wmgenmenu.c b/util/wmgenmenu.c index aff43a70..95c20e5c 100644 --- a/util/wmgenmenu.c +++ b/util/wmgenmenu.c @@ -419,7 +419,9 @@ static void find_and_write(const char *group, char *list[][2], int this_is_termi } else { 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 */ ptr = strchr(comm, '!'); while (ptr >= comm && (*ptr == '!' || isspace(*ptr)))