Skip to contentSkip to conversation

(v)sscanf handles %i improperly (+patch)

PATCH Vladimir Kondratiev 1 participant 1 message Jan 7, 2002

lore
Share & tools
lore
#0 lore raw

Sorry for 2-nd posting, but I'm afraid 1-st one was lost. Or is the issue itself not relevant? Anyway,

I found (v)sscanf included in last kernels handles %i format improperly. Currently, up to 2.4.17, %i is handled identical to %d. However, accordingly to man for sscanf,

i Matches an optionally signed integer; the next
pointer must be a pointer to int. The integer is read in base 16 if it begins with 0x' or 0X', in base 8 if it begins with `0', and in base 10 other­ wise. Only characters that correspond to the base are used.

Please, when replying, CC me: mailto:[email protected]

Patch is quite small (against 2.4.17):

vsprintf.c Tue Dec 25 23:29:31 2001 renamed from vsprintf.c.orig Thu Oct 11 20:17:22 2001 +2 -1
@@ -616,8 +616,9 @@
         case 'X':
             base = 16;
             break;
-        case 'd':
         case 'i':
+            base = 0; /* autodetect */
+        case 'd':
             is_sign = 1;
         case 'u':
             break;