[PATCH] scanf broken in lib for %i (hex/oct) in 2.4.18

Peter T. Breuer (ptb@it.uc3m.es)
Tue, 30 Jul 2002 10:04:14 +0200 (MET DST)


The %i directive is broken in scanf in lib/vsprintf in 2.4.18. The
problem is that when we hit a %i fmt we should start to parse the
corresponding str with simple_strtoul, passing it a 0 base value to
indicate that it should look for itself to determine if the number is
hex, octal or decimal. But the base=0 has somehow got lost from within
the case switch in some reorganization or other ..

It's broken as far back as 2.4.13 at least, but it's been fixed in
2.5.28, so marcelo should look at this. Umm .. I believe it's broken
in 2.2.20 as well. Alan?

--- vsprintf.c.orig Tue Jul 30 09:45:29 2002
+++ vsprintf.c Tue Jul 30 09:39:25 2002
@@ -618,9 +618,14 @@
base = 16;
break;
case 'd':
- case 'i':
+ base = 10;
is_sign = 1;
break;
+ case 'i':
+ /* base = 0 causes simple_strtoul to guess */
+ base = 0;
+ is_sign = 1;
+ break;
case 'u':
base = 10;
break;

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/