Fix an unsafe use of strchr in dmenu mode (#1176)

Found with valgrind
This commit is contained in:
lbonn 2020-09-02 15:46:44 +02:00 committed by GitHub
parent 2fbdf71951
commit e4e59b99ea
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 2 deletions

View File

@ -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 );
}