public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libc/9913] New: libc's function strverscmp() has a bug
@ 2009-02-27 20:01 jyliu at fortinet dot com
  2009-03-14 20:15 ` [Bug libc/9913] " drepper at redhat dot com
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: jyliu at fortinet dot com @ 2009-02-27 20:01 UTC (permalink / raw)
  To: glibc-bugs

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.


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

* [Bug libc/9913] libc's function strverscmp() has a bug
  2009-02-27 20:01 [Bug libc/9913] New: libc's function strverscmp() has a bug jyliu at fortinet dot com
@ 2009-03-14 20:15 ` drepper at redhat dot com
  2009-04-07  6:08 ` jakub at redhat dot com
  2009-04-07  6:52 ` drepper at redhat dot com
  2 siblings, 0 replies; 5+ messages in thread
From: drepper at redhat dot com @ 2009-03-14 20:15 UTC (permalink / raw)
  To: glibc-bugs


------- Additional Comments From drepper at redhat dot com  2009-03-14 20:15 -------
I applied the patch.

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


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.


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

* [Bug libc/9913] libc's function strverscmp() has a bug
  2009-02-27 20:01 [Bug libc/9913] New: libc's function strverscmp() has a bug jyliu at fortinet dot com
  2009-03-14 20:15 ` [Bug libc/9913] " drepper at redhat dot com
@ 2009-04-07  6:08 ` jakub at redhat dot com
  2009-04-07  6:52 ` drepper at redhat dot com
  2 siblings, 0 replies; 5+ messages in thread
From: jakub at redhat dot com @ 2009-04-07  6:08 UTC (permalink / raw)
  To: glibc-bugs


------- Additional Comments From jakub at redhat dot com  2009-04-07 06:08 -------
Unfortunately this broke something more important:

#include <string.h>
#include <stdio.h>

int
main ()
{
  int rc = strverscmp ("2.6.21", "2.6.20");
  printf ("2.6.21 %s 2.6.20\n", (rc < 0 ? "<" : rc == 0 ? "=" : ">"));
  rc = strverscmp ("2.6.20", "2.6.21");
  printf ("2.6.20 %s 2.6.21\n", (rc < 0 ? "<" : rc == 0 ? "=" : ">"));
}

now prints:
2.6.21 < 2.6.20
2.6.20 < 2.6.21
while it used to correctly print:
2.6.21 > 2.6.20
2.6.20 < 2.6.21

Seems it wasn't the change in proposed in the original comment, but the
follow-up cleanups.

-- 


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.


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

* [Bug libc/9913] libc's function strverscmp() has a bug
  2009-02-27 20:01 [Bug libc/9913] New: libc's function strverscmp() has a bug jyliu at fortinet dot com
  2009-03-14 20:15 ` [Bug libc/9913] " drepper at redhat dot com
  2009-04-07  6:08 ` jakub at redhat dot com
@ 2009-04-07  6:52 ` drepper at redhat dot com
  2 siblings, 0 replies; 5+ messages in thread
From: drepper at redhat dot com @ 2009-04-07  6:52 UTC (permalink / raw)
  To: glibc-bugs


------- Additional Comments From drepper at redhat dot com  2009-04-07 06:52 -------
Fixed in cvs.

-- 


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.


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

* [Bug libc/9913] libc's function strverscmp() has a bug
       [not found] <bug-9913-131@http.sourceware.org/bugzilla/>
@ 2014-07-01 20:45 ` fweimer at redhat dot com
  0 siblings, 0 replies; 5+ messages in thread
From: fweimer at redhat dot com @ 2014-07-01 20:45 UTC (permalink / raw)
  To: glibc-bugs

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

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] 5+ messages in thread

end of thread, other threads:[~2014-07-01 20:45 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-02-27 20:01 [Bug libc/9913] New: libc's function strverscmp() has a bug jyliu at fortinet dot com
2009-03-14 20:15 ` [Bug libc/9913] " drepper at redhat dot com
2009-04-07  6:08 ` jakub at redhat dot com
2009-04-07  6:52 ` drepper at redhat dot com
     [not found] <bug-9913-131@http.sourceware.org/bugzilla/>
2014-07-01 20:45 ` 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).