lkml.org 
[lkml]   [2003]   [Mar]   [11]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] vsscanf do not convert hex numbers starting with a non-digit
Date
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi,

I found the following little bug in 2.4.19. I did not try newer kernels.

vsscanf refuses to convert a hex number starting with a nondecimal digit like:

char *buf="ff";
unsigned ff=0;
sscanf( buf, "%x", &ff ); /* fails: nothing is converted */

Here is a patch that corrects that behaviour:

- --- linux/lib/vsprintf.c 2001-10-11 20:17:22.000000000 +0200
+++ linux.patched/lib/vsprintf.c 2003-03-11 11:52:08.000000000 +0100
@@ -637,7 +637,7 @@
while (isspace(*str))
str++;

- - if (!*str || !isdigit(*str))
+ if (!*str || !(isdigit(*str) || (base==16 && isxdigit(*str))))
break;

switch(qualifier) {

Torsten
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.7 (GNU/Linux)
iD8DBQE+bcI7wicyCTir8T4RAgsPAKCZtX+R9tljalegoC4z7xbTo3p38ACfUIYv
5xgo+tQqj8TZmQOM4W0MqqY=
=D9hc
-----END PGP SIGNATURE-----
-
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/
\
 
 \ /
  Last update: 2005-03-22 13:33    [W:0.023 / U:5.116 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site