public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libc/16640] New: string/strtok.c: undefined behaviour inconsistent between x86 and other generic code
@ 2014-02-26 20:35 kyle at redhat dot com
  2014-02-27  6:54 ` [Bug libc/16640] " carlos at redhat dot com
                   ` (7 more replies)
  0 siblings, 8 replies; 10+ messages in thread
From: kyle at redhat dot com @ 2014-02-26 20:35 UTC (permalink / raw)
  To: glibc-bugs

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

            Bug ID: 16640
           Summary: string/strtok.c: undefined behaviour inconsistent
                    between x86 and other generic code
           Product: glibc
           Version: unspecified
            Status: NEW
          Severity: minor
          Priority: P2
         Component: libc
          Assignee: unassigned at sourceware dot org
          Reporter: kyle at redhat dot com
                CC: drepper.fsp at gmail dot com

Created attachment 7444
  --> https://sourceware.org/bugzilla/attachment.cgi?id=7444&action=edit
make string/strtok match x86

The strtok.S implementations for x86_64 and i386 vary from the generic
string/strtok.c version. In the former case, if str == NULL, and the saved
string is also NULL, the strtok call returns NULL.

In contrast, the string/strtok.c call proceeds to pass s = olds = NULL to
strspn which consequently crashes.

While this behaviour is probably permissible, it results in odd portability
issues where the behaviour can't be reproduced on x86_64. As well, the generic
versions in the BSD libc I looked at (which appears to date back to 4.3BSD or
earlier...) also checks for the (s = olds) == NULL condition and handles it, so
we have a bit of precedent here.

Attached is a patch which brings the generic string/strtok.c in-line with i386,
x86_64 and BSD. It seems better to do that, rather than suddenly make working
code SIGSEGV on x86_64...

regards, Kyle

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


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

end of thread, other threads:[~2015-08-27 22:21 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-02-26 20:35 [Bug libc/16640] New: string/strtok.c: undefined behaviour inconsistent between x86 and other generic code kyle at redhat dot com
2014-02-27  6:54 ` [Bug libc/16640] " carlos at redhat dot com
2014-02-27 12:14   ` Ondřej Bílka
2014-02-27 12:14 ` neleai at seznam dot cz
2014-02-27 15:00 ` carlos at redhat dot com
2014-02-27 17:19 ` kyle at redhat dot com
2014-02-27 18:44 ` carlos at redhat dot com
2014-02-27 18:48 ` kyle at redhat dot com
2014-06-13  6:45 ` fweimer at redhat dot com
2015-08-27 22:21 ` [Bug string/16640] " jsm28 at gcc dot gnu.org

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