Re: is there small mistake in lib/vsprintf.c of kernel 2.4.20 ?

viro@parcelfarce.linux.theplanet.co.uk
Fri, 2 May 2003 10:50:18 +0100


On Fri, May 02, 2003 at 11:42:36AM +0200, Bodo Rzany wrote:

> > IOW, %d _does_ mean base=10. base=0 is %i. That goes both for kernel and
> > userland implementations of scanf family (and for any standard-compliant
> > implementation, for that matter).
>
> As I can see, 'base=10' is used for all conversions except for '%x' and
> '%o'. If '%i' or '%u' are given, base should be really set to 0, what is
> not the case (it is fixed to 10 instead!).

Sorry - in 2.4 it's really broken. What we should have:
%d -> 10
%i -> 0
%o -> 8
%u -> 10
%x -> 16
(note: %u is decimal-only; see manpage).

Fix (2.4-only, 2.5 is OK as it is):

--- S21-rc1/lib/vsprintf.c Fri Jul 12 11:25:33 2002
+++ /tmp/vsprintf.c Fri May 2 05:46:07 2003
@@ -616,8 +616,9 @@
case 'X':
base = 16;
break;
- case 'd':
case 'i':
+ base = 0;
+ case 'd':
is_sign = 1;
case 'u':
break;
-
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/