Bug#69278: libc6 sscanf gives inconsistent results.
Package: libc6
Version: 2.1.3-10
I am using the following code:
File: testsscanf.c
#include <stdio.h>
main(int argc, char *argv[]){
char tmp[4];
int x;
strncpy(tmp, argv[1], 2);
tmp[2]= 0;
sscanf(tmp, "%i", &x);
printf("tmp= %s, x= %i\n", tmp, x);
}
This is what I get when invoking the compiled version with the following
arguments:
bach:~>./testsscanf 04
tmp= 04, x= 4
bach:~>./testsscanf 05
tmp= 05, x= 5
bach:~>./testsscanf 06
tmp= 06, x= 6
bach:~>./testsscanf 07
tmp= 07, x= 7
bach:~>./testsscanf 08
tmp= 08, x= 0
bach:~>./testsscanf 08
tmp= 08, x= 0
bach:~>./testsscanf 09
tmp= 09, x= 0
bach:~>./testsscanf 10
tmp= 10, x= 10
bach:~>./testsscanf 11
tmp= 11, x= 11
As you can see, everything works fine except when using the strings '08' and
'09' which are converted to the integer 0, when they should be converted to 8
and 9 respecively.
I am using Debian 2.1, kernel version 2.2.16.
Thanks
Arturo Galvan.
Reply to: