[PATCH] Fix %x parsing in vsscanf()

From: Deepak Saxena
Date: Tue Sep 23 2003 - 16:13:06 EST



The existing code in kernel/vsprintf.c:vsscanf() does not properly
handle the case where the format is specfied as %x or %X and the
string contains the number in the format "0xinteger". Instead of
reading "0xinteger", the code currently only sees the '0' and treats
the 'x' as a delimiter. Following patch (against 2.4 and 2.6) fixes
this. Another option is to put the check in simple_strtoul() and
simple_strtoull() if that is preferred. I like this better b/c
we only have the check once.

Please apply,
~Deepak

===== lib/vsprintf.c 1.2 vs edited =====
--- 1.2/lib/vsprintf.c Mon Aug 11 04:54:01 2003
+++ edited/lib/vsprintf.c Tue Sep 23 13:50:50 2003
@@ -615,6 +615,8 @@
case 'x':
case 'X':
base = 16;
+ if(str[0] == '0' && (str[1] == 'x' || str[1] == 'X'))
+ str += 2;
break;
case 'd':
case 'i':


--
Deepak Saxena
MontaVista Software - Powering the Embedded Revolution - www.mvista.com
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/