mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] Fix %x parsing in vsscanf()
@ 2003-09-23 21:22 Deepak Saxena
  2003-09-23 21:26 ` viro
  2003-09-23 21:28 ` Linus Torvalds
  0 siblings, 2 replies; 8+ messages in thread
From: Deepak Saxena @ 2003-09-23 21:22 UTC (permalink / raw)
  To: linux-kernel; +Cc: torvalds, marcelo.tosatti


The existing code in kernel/vsprintf.c:vsscanf() does not properly 
handle the case where the format is specfied as %x or %X and the
string contains the number in the format "0xinteger". Instead of
reading "0xinteger", the code currently only sees the '0' and treats
the 'x' as a delimiter. Following patch (against 2.4 and 2.6) fixes
this.  Another option is to put the check in simple_strtoul() and
simple_strtoull() if that is preferred. I like this better b/c
we only have the check once.

Please apply,
~Deepak

===== lib/vsprintf.c 1.2 vs edited =====
--- 1.2/lib/vsprintf.c	Mon Aug 11 04:54:01 2003
+++ edited/lib/vsprintf.c	Tue Sep 23 13:50:50 2003
@@ -615,6 +615,8 @@
 		case 'x':
 		case 'X':
 			base = 16;
+			if(str[0] == '0' && (str[1] == 'x' || str[1] == 'X'))
+				str += 2;
 			break;
 		case 'd':
 		case 'i':


-- 
Deepak Saxena
MontaVista Software - Powering the Embedded Revolution - www.mvista.com

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2003-09-24  0:55 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-09-23 21:22 [PATCH] Fix %x parsing in vsscanf() Deepak Saxena
2003-09-23 21:26 ` viro
2003-09-23 21:28 ` Linus Torvalds
2003-09-23 21:35   ` viro
2003-09-23 22:16     ` Deepak Saxena
2003-09-23 22:26       ` viro
2003-09-24  1:02         ` Deepak Saxena
2003-09-24  0:55           ` viro

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®