[Bug libc/18246] New: scanf "%2d" can incorrectly parse "0x" same for "%2f" with "1e"
nszabolcs at gmail dot com
sourceware-bugzilla@sourceware.org
Fri Apr 10 12:45:00 GMT 2015
https://sourceware.org/bugzilla/show_bug.cgi?id=18246
Bug ID: 18246
Summary: scanf "%2d" can incorrectly parse "0x" same for "%2f"
with "1e"
Product: glibc
Version: unspecified
Status: NEW
Severity: normal
Priority: P2
Component: libc
Assignee: unassigned at sourceware dot org
Reporter: nszabolcs at gmail dot com
CC: drepper.fsp at gmail dot com
BZ #1765 was closed with won't fix, 0x is another similar corner case.
0x prefix should not be parsed as a valid decimal number.
following code prints:
got 1 fields (x=0), expected 0
got 1 fields (y=1), expected 0
#include <stdio.h>
int main()
{
int x;
float y;
int r;
r = sscanf("0x12", "%2d", &x);
if (r != 0)
printf("got %d fields (x=%d), expected 0\n", r, x);
r = sscanf("1e12", "%2f", &y);
if (r != 0)
printf("got %d fields (y=%g), expected 0\n", r, y);
}
--
You are receiving this mail because:
You are on the CC list for the bug.
More information about the Glibc-bugs
mailing list