2002-07-30 08:00:56

by Peter T. Breuer

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


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