summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorPaul Nasrat <pnasrat@redhat.com>2007-02-22 14:16:27 +0000
committerPaul Nasrat <pnasrat@redhat.com>2007-02-22 14:16:27 +0000
commit40d26f7bcb98b7d71b993cb9c3151db8855dc9ba (patch)
treeb890f9861e02d6c80698a358ddf00fd055fce4c3 /lib
parenta465e0637a2630c167d0e5338922f2a26a7edf01 (diff)
downloadrpm-40d26f7bcb98b7d71b993cb9c3151db8855dc9ba.tar.gz
rpm-40d26f7bcb98b7d71b993cb9c3151db8855dc9ba.tar.bz2
rpm-40d26f7bcb98b7d71b993cb9c3151db8855dc9ba.zip
This patch from Peter Bowen fixes rpm version comparison for strings with
trailing null segments (rh#178798).
Diffstat (limited to 'lib')
-rw-r--r--lib/rpmvercmp.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/lib/rpmvercmp.c b/lib/rpmvercmp.c
index 5963bf27a..a66b568e5 100644
--- a/lib/rpmvercmp.c
+++ b/lib/rpmvercmp.c
@@ -39,6 +39,9 @@ int rpmvercmp(const char * a, const char * b)
while (*one && !xisalnum(*one)) one++;
while (*two && !xisalnum(*two)) two++;
+ /* If we ran to the end of either, we are finished with the loop */
+ if (!(*one && *two)) break;
+
str1 = one;
str2 = two;
@@ -64,9 +67,13 @@ int rpmvercmp(const char * a, const char * b)
*str2 = '\0';
/*@=boundswrite@*/
+ /* this cannot happen, as we previously tested to make sure that */
+ /* the first string has a non-null segment */
+ if (one == str1) return -1; /* arbitrary */
+
/* take care of the case where the two version segments are */
/* different types: one numeric, the other alpha (i.e. empty) */
- if (one == str1) return -1; /* arbitrary */
+ /* numeric segments are always newer than alpha segments */
/* XXX See patch #60884 (and details) from bugzilla #50977. */
if (two == str2) return (isnum ? 1 : -1);