summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorlbonn <lbonn@users.noreply.github.com>2020-09-02 15:46:44 +0200
committerGitHub <noreply@github.com>2020-09-02 15:46:44 +0200
commite4e59b99ea5de1f73c990499c9e02b2484042cb2 (patch)
tree67c00de73288a95cfa7d4b9c61b5411be5aeb99c
parent2fbdf7195181bc272775b1c9413e543b1a627819 (diff)
Fix an unsafe use of strchr in dmenu mode (#1176)
Found with valgrind
-rw-r--r--source/dialogs/dmenu.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/source/dialogs/dmenu.c b/source/dialogs/dmenu.c
index d66eddd7..65235710 100644
--- a/source/dialogs/dmenu.c
+++ b/source/dialogs/dmenu.c
@@ -123,8 +123,11 @@ static void read_add ( DmenuModePrivateData * pd, char *data, gsize len )
pd->cmd_list[pd->cmd_list_length].icon_name = NULL;
pd->cmd_list[pd->cmd_list_length].meta = NULL;
pd->cmd_list[pd->cmd_list_length].info = NULL;
- char *end = strchr ( data, '\0' );
- if ( end != NULL ) {
+ char *end = data;
+ while ( end < data + len && *end != '\0' ) {
+ end++;
+ }
+ if ( end != data + len ) {
data_len = end - data;
dmenuscript_parse_entry_extras ( NULL, &( pd->cmd_list[pd->cmd_list_length] ), end + 1, len - data_len );
}