This is the mail archive of the
glibc-bugs@sourceware.org
mailing list for the glibc project.
[Bug libc/18246] New: scanf "%2d" can incorrectly parse "0x" same for "%2f" with "1e"
- From: "nszabolcs at gmail dot com" <sourceware-bugzilla at sourceware dot org>
- To: glibc-bugs at sourceware dot org
- Date: Fri, 10 Apr 2015 12:45:01 +0000
- Subject: [Bug libc/18246] New: scanf "%2d" can incorrectly parse "0x" same for "%2f" with "1e"
- Auto-submitted: auto-generated
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.