printk: fix bounds checking for log_prefix
authorWilliam Douglas <william.r.douglas@gmail.com>
Tue, 1 Nov 2011 00:11:29 +0000 (17:11 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Tue, 1 Nov 2011 00:30:53 +0000 (17:30 -0700)
Currently log_prefix is testing that the first character of the log level
and facility is less than '0' and greater than '9' (which is always
false).  It should be testing to see if the character less than '0' or
greater than '9' instead.  This patch makes that change.

The code being changed worked because strtoul bombs out (endp isn't
updated) and 0 is returned anyway.

Signed-off-by: William Douglas <william.douglas@intel.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
kernel/printk.c

index 6d9dedd1145067c5dddcd376ff75d08d16464e8d..286d2c7be52c9ad44c76fa506fe62457830da5e2 100644 (file)
@@ -595,7 +595,7 @@ static size_t log_prefix(const char *p, unsigned int *level, char *special)
                /* multi digit including the level and facility number */
                char *endp = NULL;
 
-               if (p[1] < '0' && p[1] > '9')
+               if (p[1] < '0' || p[1] > '9')
                        return 0;
 
                lev = (simple_strtoul(&p[1], &endp, 10) & 7);