public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libc/13154] New: strtol, et. al. clobber endptr when base is invalid
@ 2011-09-06  2:39 bugdal at aerifal dot cx
  2011-09-08  2:33 ` [Bug libc/13154] " drepper.fsp at gmail dot com
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: bugdal at aerifal dot cx @ 2011-09-06  2:39 UTC (permalink / raw)
  To: glibc-bugs

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.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug libc/13154] strtol, et. al. clobber endptr when base is invalid
  2011-09-06  2:39 [Bug libc/13154] New: strtol, et. al. clobber endptr when base is invalid bugdal at aerifal dot cx
@ 2011-09-08  2:33 ` drepper.fsp at gmail dot com
  2011-09-08  3:35 ` bugdal at aerifal dot cx
  2014-06-27 12:09 ` fweimer at redhat dot com
  2 siblings, 0 replies; 4+ messages in thread
From: drepper.fsp at gmail dot com @ 2011-09-08  2:33 UTC (permalink / raw)
  To: glibc-bugs

http://sourceware.org/bugzilla/show_bug.cgi?id=13154

Ulrich Drepper <drepper.fsp at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |INVALID

--- Comment #1 from Ulrich Drepper <drepper.fsp at gmail dot com> 2011-09-08 02:32:44 UTC ---
There is nothing in the standard which forbids the behavior.  No change needed.

-- 
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.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug libc/13154] strtol, et. al. clobber endptr when base is invalid
  2011-09-06  2:39 [Bug libc/13154] New: strtol, et. al. clobber endptr when base is invalid bugdal at aerifal dot cx
  2011-09-08  2:33 ` [Bug libc/13154] " drepper.fsp at gmail dot com
@ 2011-09-08  3:35 ` bugdal at aerifal dot cx
  2014-06-27 12:09 ` fweimer at redhat dot com
  2 siblings, 0 replies; 4+ messages in thread
From: bugdal at aerifal dot cx @ 2011-09-08  3:35 UTC (permalink / raw)
  To: glibc-bugs

http://sourceware.org/bugzilla/show_bug.cgi?id=13154

--- Comment #2 from Rich Felker <bugdal at aerifal dot cx> 2011-09-08 03:34:51 UTC ---
You may be right, simply because I misread the "may fail" as if it were "shall
fail". Presumably an implementation may do whatever it likes when base is
invalid.

Still I think it would be nice to "fix" this.

-- 
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.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug libc/13154] strtol, et. al. clobber endptr when base is invalid
  2011-09-06  2:39 [Bug libc/13154] New: strtol, et. al. clobber endptr when base is invalid bugdal at aerifal dot cx
  2011-09-08  2:33 ` [Bug libc/13154] " drepper.fsp at gmail dot com
  2011-09-08  3:35 ` bugdal at aerifal dot cx
@ 2014-06-27 12:09 ` fweimer at redhat dot com
  2 siblings, 0 replies; 4+ messages in thread
From: fweimer at redhat dot com @ 2014-06-27 12:09 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=13154

Florian Weimer <fweimer at redhat dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
              Flags|                            |security-

-- 
You are receiving this mail because:
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2014-06-27 12:09 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-09-06  2:39 [Bug libc/13154] New: strtol, et. al. clobber endptr when base is invalid bugdal at aerifal dot cx
2011-09-08  2:33 ` [Bug libc/13154] " drepper.fsp at gmail dot com
2011-09-08  3:35 ` bugdal at aerifal dot cx
2014-06-27 12:09 ` fweimer at redhat dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).