Parse only init_debug option with non-empty argument.
authorYousong Zhou <yszhou4tech@gmail.com>
Tue, 23 Jul 2013 08:28:42 +0000 (16:28 +0800)
committerJohn Crispin <blogic@openwrt.org>
Tue, 23 Jul 2013 10:24:31 +0000 (12:24 +0200)
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 <yszhou4tech@gmail.com>
debug.c

diff --git a/debug.c b/debug.c
index 91e874f6a3ae54d4b7e5857725f786af9a5c3003..fbf1e4fb1b51def0ff0f065f165acdac2e0ae8ef 100644 (file)
--- 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]);