This is the mail archive of the
glibc-bugs@sourceware.org
mailing list for the glibc project.
[Bug libc/13154] New: strtol, et. al. clobber endptr when base is invalid
- From: "bugdal at aerifal dot cx" <sourceware-bugzilla at sourceware dot org>
- To: glibc-bugs at sources dot redhat dot com
- Date: Tue, 06 Sep 2011 02:38:38 +0000
- Subject: [Bug libc/13154] New: strtol, et. al. clobber endptr when base is invalid
- Auto-submitted: auto-generated
http://sourceware.org/bugzilla/show_bug.cgi?id=13154
Bug #: 13154
Summary: strtol, et. al. clobber endptr when base is invalid
Product: glibc
Version: unspecified
Status: NEW
Severity: normal
Priority: P2
Component: libc
AssignedTo: drepper.fsp@gmail.com
ReportedBy: bugdal@aerifal.cx
Classification: Unclassified
ISO C does not specify any behavior for strtol-family function when base is
invalid, but POSIX specifies that the functions shall fail and set errno to
EINVAL in this case. glibc's implementation does fail and sets errno, but also
clobbers the pointer pointed to by the endptr argument (with NULL). This could
break applications which assume *endptr will always remain the same or advance
after a call to strtol, even in the presence of invalid input. I see nothing in
the standards that allows glibc's behavior.
Simple test case:
char *s = "123";
strtol(s, &s, 37);
assert(s);
Wide character versions and long long/intmax_t versions, and the corresponding
unsigned versions, are also affected.
--
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.