This service will be undergoing maintenance at 20:00 UTC, 2017-04-03. It is expected to last about 30 minutes
Bug 82639 - Bad values returned from rpmvercmp from rpmlib
Bad values returned from rpmvercmp from rpmlib
Status: CLOSED DUPLICATE of bug 50977
Product: Red Hat Linux
Classification: Retired
Component: rpm (Show other bugs)
8.0
All Linux
medium Severity medium
: ---
: ---
Assigned To: Jeff Johnson
Mike McLean
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2003-01-24 05:44 EST by Alexander Kanevskiy
Modified: 2007-04-18 12:50 EDT (History)
0 users

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2003-01-24 10:54:56 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)
quick fix. (525 bytes, patch)
2003-01-24 10:03 EST, Alexander Kanevskiy
no flags Details | Diff

  None (edit)
Description Alexander Kanevskiy 2003-01-24 05:44:08 EST
From Bugzilla Helper:
User-Agent: Mozilla/5.0 (X11; U; Linux i686; ru-RU; rv:1.2.1) Gecko/20021224

Description of problem:
I'm try to idntify in own program what rpm version is newer
seem's what rpmvercmp function works incorrectly if
some alpha letters present in Release tag

Version-Release number of selected component (if applicable):


How reproducible:
Always

Steps to Reproduce:
[kad@pylesos kad]$ python
>>> import rpm
>>> rpm.labelCompare(('0', '9.2.1', '1.7x.2asp'), ('0', '9.2.1', '1.asp'))
-1
>>> rpm.labelCompare(('0', '9.2.1', '1.asp'), ('0', '9.2.1', '1.7x.2asp'))
-1
>>> rpm.labelCompare(('0', '9.2.1', '1asp'), ('0', '9.2.1', '1.7x.2asp'))
-1
>>> rpm.labelCompare(('0', '9.2.1', '1asp'), ('0', '9.2.1', '1.7x.2asp'))
-1
>>>
>>> rpm.labelCompare(('0', '9.2.1', '1'), ('0', '9.2.1', '1.7x.2'))
-1
>>> rpm.labelCompare(('0', '9.2.1', '1.7x.2'), ('0', '9.2.1', '1'))
1
>>> rpm.labelCompare(('0', '9.2.1', '1.7x.2a'), ('0', '9.2.1', '1a'))
-1
>>> rpm.labelCompare(('0', '9.2.1', '1a'), ('0', '9.2.1', '1.7x.2a'))
-1
>>>

Actual Results:  In case compare 9.2.1-1 and 9.2.1-1.7x.2 Version/Release pair -- 
rpm works correctly. In case s1=9.2.1-1aaa and s2=9.2.1-1.7x.2aaa
rpmvercmp return always -1 in any case rpmvercmp(s1,s2) or rpmvercmp(s2,s1)


Expected Results:  9.2.1-1.7x.2aaa must be newer than 9.2.1-1aaa


Additional info:
Comment 1 Jeff Johnson 2003-01-24 06:48:07 EST
rpmvercmp does what it does, has always done what it has done,
cannot and will not change.

Yes there are odd corner cases comparing alpha with digit strings.
See #50973 (from memory) for gory details.
Comment 2 Alexander Kanevskiy 2003-01-24 10:01:02 EST
I fix this function to work more gracefully in case Release consist 
versions and numbers.

Here is test. return: - is patched result, rh: is original result.
Fix me if I wrong.
Patch will be attached.

return 
 1: a is newer than b
 0: a and b are the same version
-1: b is newer than a

a: 1.asp      b: 1.7x.2asp  return:  -1 rh:  -1
a: 1.7x.2asp  b: 1.asp      return:   1 rh:  -1
a: asp1       b: asp1.7x.2  return:  -1 rh:  -1
a: asp1.7x.2  b: asp1       return:   1 rh:   1
a: 1          b: asp1.7x.2  return:   1 rh:  -1
a: asp1.7x.2  b: 1          return:  -1 rh:  -1
a: asp1       b: 1.7x.2     return:  -1 rh:  -1
a: 1.7x.2     b: asp1       return:   1 rh:  -1
a: 1          b: 1.7x.2     return:  -1 rh:  -1
a: 1.7x.2     b: 1          return:   1 rh:   1
a: 1.asp      b: 1.asp      return:   0 rh:   0
a: 1.asp      b: 0.7.3      return:   1 rh:   1
a: 3asp       b: 3.asp      return:   0 rh:   0
a: 9.0        b: 10.0       return:  -1 rh:  -1
a: 9asp       b: 10         return:  -1 rh:  -1
a: 9          b: 15.asp     return:  -1 rh:  -1
a: owl1       b: 1asp       return:  -1 rh:  -1
a: alt1       b: 1asp       return:  -1 rh:  -1
a: alt2       b: 1          return:  -1 rh:  -1
a: 0.7.2.asp  b: 0.7.3asp   return:  -1 rh:  -1
a: 0.7.2.asp  b: 0.7.2asp   return:   0 rh:   0
a: asp1       b: alt1       return:   1 rh:   1
a: ipl4mdk    b: alt0.8     return:   1 rh:   1
a: alt0.8     b: ipl4mdk    return:  -1 rh:  -1

Comment 3 Alexander Kanevskiy 2003-01-24 10:03:26 EST
Created attachment 89573 [details]
quick fix.

We can assume what we a comparing numbers only if str1 and str2 is numbers. not
only str1
Comment 4 Jeff Johnson 2003-01-24 10:11:25 EST
Again, there is no such thing as a "quick fix" for
rpmvercmp. See details at #50977.

*** This bug has been marked as a duplicate of 50977 ***
Comment 5 Alexander Kanevskiy 2003-01-24 10:54:56 EST
Yes, I agree. :)
Sorry, I don't found bug 50977.
Peter Bowen and me release same idea but in different ways.
His patch and mine produces one output. 

 
Thanks for fix in 4.2-0.55


Note You need to log in before you can comment on or make changes to this bug.