This is the mail archive of the
glibc-bugs@sourceware.org
mailing list for the glibc project.
[Bug libc/16885] New: strcmp() on sparc64 can return wrong result
- From: "baggett.patrick at gmail dot com" <sourceware-bugzilla at sourceware dot org>
- To: glibc-bugs at sourceware dot org
- Date: Tue, 29 Apr 2014 19:48:13 +0000
- Subject: [Bug libc/16885] New: strcmp() on sparc64 can return wrong result
- Auto-submitted: auto-generated
https://sourceware.org/bugzilla/show_bug.cgi?id=16885
Bug ID: 16885
Summary: strcmp() on sparc64 can return wrong result
Product: glibc
Version: 2.18
Status: NEW
Severity: normal
Priority: P2
Component: libc
Assignee: unassigned at sourceware dot org
Reporter: baggett.patrick at gmail dot com
CC: drepper.fsp at gmail dot com
In 2011, strcmp() was rewritten for sparc64 to be faster in
ad69cc2652c0422ebac3296d914c25e470498ce1 by David S. Miller. However, there is
a particularly strange case where it can return the wrong value: if the bytes
after the last bytes being compared are both zero.
e.g.
char a[2] = { 0, 0 };
char b[2] = { 1, 0 };
printf("%d", strcmp(a,b));
This should print "-1" because the first byte differs by 1. The second byte
should not be examined. However, it erroneously prints "0". Changing either
a[1] or b[1] to a non-zero value causes the "-1" to be correctly returned. For
example, this returns the correct value of -1:
char a[2] = { 0, 0xaa };
char b[2] = { 1, 0 };
printf("%d", strcmp(a,b));
--
You are receiving this mail because:
You are on the CC list for the bug.