* [PATCH] vsscanf do not convert hex numbers starting with a non-digit
@ 2003-03-11 11:02 Torsten Foertsch
2003-03-11 11:36 ` Marc-Christian Petersen
0 siblings, 1 reply; 2+ messages in thread
From: Torsten Foertsch @ 2003-03-11 11:02 UTC (permalink / raw)
To: linux-kernel
-----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-----
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] vsscanf do not convert hex numbers starting with a non-digit
2003-03-11 11:02 [PATCH] vsscanf do not convert hex numbers starting with a non-digit Torsten Foertsch
@ 2003-03-11 11:36 ` Marc-Christian Petersen
0 siblings, 0 replies; 2+ messages in thread
From: Marc-Christian Petersen @ 2003-03-11 11:36 UTC (permalink / raw)
To: Torsten Foertsch, linux-kernel
On Tuesday 11 March 2003 12:02, Torsten Foertsch wrote:
Hi Torsten,
> 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) {
http://marc.theaimsgroup.com/?l=linux-kernel&m=104687957102846&w=2
This fix was first posted since early 2.4.18-pre stage.
ciao, Marc
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2003-03-11 11:26 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-03-11 11:02 [PATCH] vsscanf do not convert hex numbers starting with a non-digit Torsten Foertsch
2003-03-11 11:36 ` Marc-Christian Petersen
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®