[PATCH] another fix for vsprintf.c in 2.4.18

From: Peter T. Breuer (ptb@it.uc3m.es)
Date: Tue Jul 30 2002 - 07:01:08 EST


Sigh - there's yet another bug in the lib/vsprintf.c implementation
of scanf. This time it's in the handling of %x. The symptom is
that "9bc" will be recongnized as hex OK, but "abc" won't be.

The problem is that the vscanf routine attemps to gobble space before
beginning to parse the number and stops at a digit. But it should, in
the case that base=16, stop at a hexadecimal digit, not only at a
decimal digit.

--- vsprintf.c.orig Tue Jul 30 09:45:29 2002
+++ vsprintf.c Tue Jul 30 13:34:04 2002
@@ -640,7 +645,7 @@
                 while (isspace(*str))
                         str++;
 
- if (!*str || !isdigit(*str))
+ if (!*str || !((base==16)?isxdigit(*str):isdigit(*str)))
                         break;
 
                 switch(qualifier) {

The case when base=8 (%o) and base=0 (%i) are OK, as in the former the
number will begin with a 0, and the latter means that we expect a
leading 0x or 0 if it's a funny number, or else it's decimal (%d).
Either way, searching for a decimal digit was always OK there. It's
only the base=16 (%x) case for which the code was broken, for the
cases when the number starts with [a-f].

Peter
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Tue Jul 30 2002 - 14:00:36 EST