Re: [PATCH] Fix %x parsing in vsscanf()

From: Deepak Saxena
Date: Tue Sep 23 2003 - 17:06:25 EST


On Sep 23 2003, at 22:35, viro@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx was caught saying:
> On Tue, Sep 23, 2003 at 02:28:12PM -0700, Linus Torvalds wrote:
> > Fixing strtoul[l] should fix vsscanf() automatically, no? So I don't see
> > the "have the check only once" argument.
>
> C99 on behaviour of %x:
>
> "Matches an optionally signed hexadecimal integer, whose format is the same as
> expected for the subject sequence of the strtoul function with the value 16
> for the base argument."
>
> IOW, strtoul() is definitely the right place to fix that.

OK, given that and your previous message, here's an updated patch:

===== lib/vsprintf.c 1.1 vs edited =====
--- 1.1/lib/vsprintf.c Tue Jan 22 19:31:16 2002
+++ edited/lib/vsprintf.c Tue Sep 23 15:07:20 2003
@@ -32,6 +32,8 @@
{
unsigned long result = 0,value;

+ if ((base == 16) && (cp[0] == '0' && (cp[1] == 'x' || cp[1] == 'X')))
+ cp += 2;
if (!base) {
base = 10;
if (*cp == '0') {
@@ -76,6 +78,8 @@
{
unsigned long long result = 0,value;

+ if ((base == 16) && (cp[0] == '0' && (cp[1] == 'x' || cp[1] == 'X')))
+ cp += 2;
if (!base) {
base = 10;
if (*cp == '0') {

--
Deepak Saxena
MontaVista Software - Powering the Embedded Revolution - www.mvista.com
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/