From: Yousong Zhou Date: Tue, 23 Jul 2013 08:28:42 +0000 (+0800) Subject: Parse only init_debug option with non-empty argument. X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=b5f942d6392b9721b686ec504134e88e55e61cb0;p=oweals%2Fprocd.git Parse only init_debug option with non-empty argument. Matching empty string makes rm_so and rm_eo of struct regmatch_t have the same value, in this case both of them are 11. This causes a call to atoi("\0") whose return value 0 is just the initial value of 'debug'. Signed-off-by: Yousong Zhou --- diff --git a/debug.c b/debug.c index 91e874f..fbf1e4f 100644 --- a/debug.c +++ b/debug.c @@ -36,7 +36,7 @@ void debug_init(void) line[r] = '\0'; close(fd); - regcomp(&pat_cmdline, "init_debug=([0-9]*)", REG_EXTENDED); + regcomp(&pat_cmdline, "init_debug=([0-9]+)", REG_EXTENDED); if (!regexec(&pat_cmdline, line, 2, matches, 0)) { line[matches[1].rm_eo] = '\0'; debug = atoi(&line[matches[1].rm_so]);