From 64cc9685a1bfa789dbcc447d68493691727e11ba Mon Sep 17 00:00:00 2001 From: Andre Noll Date: Sat, 3 Oct 2015 22:48:38 +0000 Subject: [PATCH] play: Handle empty arguments to --key-map gracefully. Executing para_play with an empty argument to --key-map results in a read which starts one byte past the allocated buffer: ==24163== Invalid read of size 1 ==24163== at 0x402A1DA: index (mc_replace_strmem.c:223) ==24163== by 0x804DA22: main (play.c:187) ==24163== Address 0x498e331 is 0 bytes after a block of size 1 alloc'd This patch fixes the issue by rejecting empty arguments as invalid. --- play.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/play.c b/play.c index 61c30aed..1b3cc933 100644 --- a/play.c +++ b/play.c @@ -184,10 +184,10 @@ static void parse_config_or_die(int argc, char *argv[]) loglevel = get_loglevel_by_name(conf.loglevel_arg); } for (i = 0; i < conf.key_map_given; i++) { - char *s = strchr(conf.key_map_arg[i] + 1, ':'); - if (s) + char *kma = conf.key_map_arg[i]; + if (*kma && strchr(kma + 1, ':')) continue; - PARA_EMERG_LOG("invalid key map arg: %s\n", conf.key_map_arg[i]); + PARA_EMERG_LOG("invalid key map arg: %s\n", kma); goto err; } free(config_file); -- 2.39.5