This is the mail archive of the
glibc-bugs@sourceware.org
mailing list for the glibc project.
[Bug libc/9913] New: libc's function strverscmp() has a bug
- From: "jyliu at fortinet dot com" <sourceware-bugzilla at sourceware dot org>
- To: glibc-bugs at sources dot redhat dot com
- Date: 27 Feb 2009 20:01:14 -0000
- Subject: [Bug libc/9913] New: libc's function strverscmp() has a bug
- Reply-to: sourceware-bugzilla at sourceware dot org
This bug exists in all versions of glibc. Given 3 strings,
string_A: "B0075022800016.gbp.corp.com"
string_B: "B007502280067.gbp.corp.com"
string_C: "B007502357019.GBP.CORP.COM",
Using strverscmp() on these 3 strings, get the following result:
string_A < string_B < string_C < string_A
where string_C < string_A is wrong because .0075022800016 < .007502357019 (the
leading . is for fractionnal number because from man page a '.' should be added
before leading 0's).
I have a fix for this:
Index: string/strverscmp.c
===================================================================
RCS file: /cvs/glibc/libc/string/strverscmp.c,v
retrieving revision 1.6
diff -u -r1.6 strverscmp.c
--- string/strverscmp.c 4 Aug 2002 09:14:35 -0000 1.6
+++ string/strverscmp.c 27 Feb 2009 19:58:55 -0000
@@ -69,7 +69,7 @@
CMP, CMP, CMP, CMP, CMP, CMP, CMP, CMP,
/* S_I */ CMP, -1, -1, CMP, +1, LEN, LEN, CMP,
+1, LEN, LEN, CMP, CMP, CMP, CMP, CMP,
- /* S_F */ CMP, CMP, CMP, CMP, CMP, LEN, CMP, CMP,
+ /* S_F */ CMP, CMP, CMP, CMP, CMP, CMP, CMP, CMP,
CMP, CMP, CMP, CMP, CMP, CMP, CMP, CMP,
/* S_Z */ CMP, +1, +1, CMP, -1, CMP, CMP, CMP,
-1, CMP, CMP, CMP
[The reason is that after entring state S_F, CMP should be the only option to
compare strings.]
--
Summary: libc's function strverscmp() has a bug
Product: glibc
Version: unspecified
Status: NEW
Severity: normal
Priority: P2
Component: libc
AssignedTo: drepper at redhat dot com
ReportedBy: jyliu at fortinet dot com
CC: glibc-bugs at sources dot redhat dot com
http://sourceware.org/bugzilla/show_bug.cgi?id=9913
------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.