Bug in scanf &Co
Igor Pechtchanski
pechtcha@cs.nyu.edu
Wed Jun 9 21:01:00 GMT 2004
Hi,
There is a bug in the newlib scanf family implementation (actually, in
__svfscanf_r in libc/stdio/vfscanf.c) that causes it to read strings of
the form 0x0+ incorrectly. Attached is a testcase that demonstrates the
bug on Cygwin. I suspect the following change:
<http://sources.redhat.com/ml/newlib-cvs/2004-q2/msg00008.html>.
HTH,
Igor
--
http://cs.nyu.edu/~pechtcha/
|\ _,,,---,,_ pechtcha@cs.nyu.edu
ZZZzz /,`.-'`' -. ;-;;,_ igor@watson.ibm.com
|,4- ) )-,_. ,\ ( `'-' Igor Pechtchanski, Ph.D.
'---''(_/--' `-'\_) fL a.k.a JaguaR-R-R-r-r-r-.-.-. Meow!
"I have since come to realize that being between your mentor and his route
to the bathroom is a major career booster." -- Patrick Naughton
-------------- next part --------------
#include <stdlib.h>
#include <stdio.h>
int main(char ac, char *av[]) {
const char *str1 = "0x1 0x0 0x3";
const char *str2 = "0x1 0x2 0x3";
unsigned int i,j,k;
sscanf(str1, "%x %x %x", &i, &j, &k);
printf("Values are: %x %x %x\n", i, j, k);
sscanf(str2, "%x %x %x", &i, &j, &k);
printf("Values are: %x %x %x\n", i, j, k);
}
More information about the Newlib
mailing list