]> git.pld-linux.org Git - packages/rpm.git/commitdiff
- check namespaces of dependencies in _rpmtsCheck, don't compare strings blindly
authorJan Rękorajski <baggins@pld-linux.org>
Fri, 30 Nov 2012 12:26:03 +0000 (13:26 +0100)
committerJan Rękorajski <baggins@pld-linux.org>
Fri, 30 Nov 2012 12:26:03 +0000 (13:26 +0100)
This patch fixes a bug with ntpd package we encoutered:
- ntpdate has "Conflicts: ntp < 4.2.0-3"
- ntpd has "Provides: ntp = 4.2.4" and "Provides: user(ntp)"
now, if ntpdate is installed then attempt to install ntpd causes
_rpmtsCheck to compare "C: ntp" to both "P: ntp" AND THEN "P: user(ntp)"
due to lack of dependency namespace check. Side effect of this is
infinite loop in _rpmtsCheck due to inner workings of rpm dependency
iterators.

rpm-namespace-compare.patch
rpm.spec

index 7a2dfa889281db755efe09c2c2bb2059dee83110..eeb38c891df0408ab2a76bcc1ea4d4c500d0aaa4 100644 (file)
      /* Different names (and/or name.arch's) don't overlap. */
      if (rpmdsNAcmp(A, B)) {
        result = 0;
+diff -ur rpm-5.4.10/lib/depends.c rpm-5.4.10.nstype/lib/depends.c
+--- rpm-5.4.10/lib/depends.c   2012-11-30 13:03:40.350619256 +0100
++++ rpm-5.4.10.nstype/lib/depends.c    2012-11-30 12:08:01.266204377 +0100
+@@ -16,6 +16,7 @@
+ #define       _RPMDB_INTERNAL         /* XXX response cache needs dbiOpen et al. */
+ #include <rpmdb.h>
++#define       _RPMDS_INTERNAL
+ #define       _RPMEVR_INTERNAL
+ #include <rpmds.h>
+ #include <rpmfi.h>
+@@ -1570,6 +1579,7 @@
+               /*@null@*/ rpmds dirnames,
+               /*@null@*/ rpmds linktos,
+               /*@null@*/ const char * depName,
++              nsType depNS,
+               rpmuint32_t tscolor, int adding)
+       /*@globals rpmGlobalMacroContext, h_errno,
+               fileSystem, internalState @*/
+@@ -1579,6 +1589,7 @@
+     rpmps ps = rpmtsProblems(ts);
+     rpmuint32_t dscolor;
+     const char * Name;
++    nsType NSType;
+     int terminate = 2;                /* XXX terminate if rc >= terminate */
+     int rc;
+     int ourrc = 0;
+@@ -1598,6 +1609,11 @@
+       if (depName != NULL && strcmp(depName, Name))
+           continue;
++      NSType = rpmdsNSType(requires);
++
++      if (depNS != RPMNS_TYPE_UNKNOWN && depNS != NSType)
++          continue;
++
+       /* Ignore colored requires not in our rainbow. */
+       dscolor = rpmdsColor(requires);
+       if (tscolor && dscolor && !(tscolor & dscolor))
+@@ -1639,6 +1659,11 @@
+       if (depName != NULL && strcmp(depName, Name))
+           continue;
++      NSType = rpmdsNSType(conflicts);
++
++      if (depNS != RPMNS_TYPE_UNKNOWN && depNS != NSType)
++          continue;
++
+       /* Ignore colored conflicts not in our rainbow. */
+       dscolor = rpmdsColor(conflicts);
+       if (tscolor && dscolor && !(tscolor & dscolor))
+@@ -1676,6 +1703,11 @@
+       if (depName != NULL && strcmp(depName, Name))
+           continue;
++      NSType = rpmdsNSType(dirnames);
++
++      if (depNS != RPMNS_TYPE_UNKNOWN && depNS != NSType)
++          continue;
++
+       /* Ignore colored dirnames not in our rainbow. */
+       dscolor = rpmdsColor(dirnames);
+       if (tscolor && dscolor && !(tscolor & dscolor))
+@@ -1724,6 +1758,11 @@
+       if (depName != NULL && strcmp(depName, Name))
+           continue;
++      NSType = rpmdsNSType(linktos);
++
++      if (depNS != RPMNS_TYPE_UNKNOWN && depNS != NSType)
++          continue;
++
+       /* Ignore colored linktos not in our rainbow. */
+       dscolor = rpmdsColor(linktos);
+       if (tscolor && dscolor && !(tscolor & dscolor))
+@@ -1771,7 +1812,7 @@
+  * @param adding      dependency is from added package set?
+  * @return            0 no problems found
+  */
+-static int checkPackageSet(rpmts ts, const char * depName,
++static int checkPackageSet(rpmts ts, const char * depName, nsType depNS,
+               /*@only@*/ /*@null@*/ rpmmi mi, int adding)
+       /*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/
+       /*@modifies ts, mi, rpmGlobalMacroContext, fileSystem, internalState @*/
+@@ -1816,7 +1857,7 @@
+       rc = checkPackageDeps(ts, he->p.str,
+               requires, conflicts, dirnames, linktos,
+-              depName, tscolor, adding);
++              depName, depNS, tscolor, adding);
+       (void)rpmdsFree(linktos);
+       linktos = NULL;
+@@ -1844,7 +1886,7 @@
+  * @param depName     requires name
+  * @return            0 no problems found
+  */
+-static int checkDependentPackages(rpmts ts, const char * depName)
++static int checkDependentPackages(rpmts ts, const char * depName, nsType depNS)
+       /*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/
+       /*@modifies ts, rpmGlobalMacroContext, fileSystem, internalState @*/
+ {
+@@ -1854,7 +1896,7 @@
+     if (rpmtsGetRdb(ts) != NULL) {
+       rpmmi mi;
+       mi = rpmtsInitIterator(ts, RPMTAG_REQUIRENAME, depName, 0);
+-      rc = checkPackageSet(ts, depName, mi, 0);
++      rc = checkPackageSet(ts, depName, depNS, mi, 0);
+     }
+     return rc;
+ }
+@@ -1865,7 +1908,7 @@
+  * @param depName     conflicts name
+  * @return            0 no problems found
+  */
+-static int checkDependentConflicts(rpmts ts, const char * depName)
++static int checkDependentConflicts(rpmts ts, const char * depName, nsType depNS)
+       /*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/
+       /*@modifies ts, rpmGlobalMacroContext, fileSystem, internalState @*/
+ {
+@@ -1875,7 +1918,7 @@
+     if (rpmtsGetRdb(ts) != NULL) {
+       rpmmi mi;
+       mi = rpmtsInitIterator(ts, RPMTAG_CONFLICTNAME, depName, 0);
+-      rc = checkPackageSet(ts, depName, mi, 1);
++      rc = checkPackageSet(ts, depName, depNS, mi, 1);
+     }
+     return rc;
+@@ -1939,7 +1985,7 @@
+       rc = checkPackageDeps(ts, rpmteNEVRA(p),
+                       requires, conflicts, dirnames, linktos,
+-                      NULL, tscolor, 1);
++                      NULL, RPMNS_TYPE_UNKNOWN, tscolor, 1);
+       if (rc && (ourrc = rc) >= terminate)
+           break;
+@@ -1963,7 +2011,7 @@
+ #endif
+           /* Adding: check provides key against conflicts matches. */
+-          if (checkDependentConflicts(ts, depName))
++          if (checkDependentConflicts(ts, depName, rpmdsNSType(provides)))
+               rc = 1;
+       }
+       if (rc && (ourrc = rc) >= terminate)
+@@ -1975,7 +2026,7 @@
+           depName = _free(depName);
+           depName = xstrdup(rpmfiFN(fi));
+           /* Adding: check filename against conflicts matches. */
+-          if (checkDependentConflicts(ts, depName))
++          if (checkDependentConflicts(ts, depName, RPMNS_TYPE_UNKNOWN))
+               rc = 1;
+       }
+       if (rc && (ourrc = rc) >= terminate)
+@@ -2006,7 +2058,7 @@
+           depName = xstrdup(rpmdsN(provides));
+           /* Erasing: check provides against requiredby matches. */
+-          if (checkDependentPackages(ts, depName))
++          if (checkDependentPackages(ts, depName, rpmdsNSType(provides)))
+               rc = 1;
+       }
+       if (rc && (ourrc = rc) >= terminate)
+@@ -2018,7 +2070,7 @@
+           depName = _free(depName);
+           depName = xstrdup(rpmfiFN(fi));
+           /* Erasing: check filename against requiredby matches. */
+-          if (checkDependentPackages(ts, depName))
++          if (checkDependentPackages(ts, depName, RPMNS_TYPE_UNKNOWN))
+               rc = 1;
+       }
+       if (rc && (ourrc = rc) >= terminate)
+@@ -2039,7 +2091,7 @@
+       const char * dep = NULL;
+       int adding = 2;
+       tscolor = 0;    /* XXX no coloring for transaction dependencies. */
+-      rc = checkPackageDeps(ts, tsNEVRA, R, C, D, L, dep, tscolor, adding);
++      rc = checkPackageDeps(ts, tsNEVRA, R, C, D, L, dep, RPMNS_TYPE_UNKNOWN, tscolor, adding);
+     }
+     if (rc && (ourrc = rc) >= terminate)
+       goto exit;
+diff -ur rpm-5.4.10/lib/rpmal.c rpm-5.4.10.nstype/lib/rpmal.c
+--- rpm-5.4.10/lib/rpmal.c     2012-04-15 23:20:57.000000000 +0200
++++ rpm-5.4.10.nstype/lib/rpmal.c      2012-11-30 12:57:52.579432191 +0100
+@@ -61,6 +65,7 @@
+     alKey pkgKey;             /*!< Containing package. */
+ /*@observer@*/
+     const char * entry;               /*!< Dependency name. */
++    nsType entryNS;           /*!< Dependency namesapce. */
+     unsigned short entryLen;  /*!< No. of bytes in name. */
+     unsigned short entryIx;   /*!< Dependency index. */
+     indexEntryType_e type;    /*!< Type of available item. */
+@@ -271,6 +276,9 @@
+     if (lenchk)
+       return lenchk;
++    if (a->entryNS != b->entryNS)
++      return -1;
++
+     return strcmp(a->entry, b->entry);
+ }
+@@ -305,6 +313,7 @@
+       aie->pkgKey = pkgKey;
+ /*@-assignexpose@*/
+       aie->entry = Name;
++      aie->entryNS = rpmdsNSType(provides);
+ /*@=assignexpose@*/
+       aie->entryLen = (unsigned short)strlen(Name);
+       ix = rpmdsIx(provides);
+@@ -421,6 +431,7 @@
+       memset(alloca(sizeof(*needle)), 0, sizeof(*needle));
+     /*@-assignexpose -temptrans@*/
+     needle->entry = KName;
++    needle->entryNS = rpmdsNSType(ds);
+     /*@=assignexpose =temptrans@*/
+     needle->entryLen = (unsigned short)strlen(needle->entry);
index d1116940e4769d049826eb06252e013b6ddf1781..4177fd8134d8dfd34ad621b2bc524064fe972428 100644 (file)
--- a/rpm.spec
+++ b/rpm.spec
@@ -52,7 +52,7 @@ Summary(ru.UTF-8):    Менеджер пакетов от RPM
 Summary(uk.UTF-8):     Менеджер пакетів від RPM
 Name:          rpm
 Version:       5.4.10
-Release:       35.1
+Release:       35.2
 License:       LGPL
 Group:         Base
 # http://rpm5.org/files/rpm/rpm-5.4/rpm-5.4.10-0.20120706.src.rpm
This page took 0.053924 seconds and 4 git commands to generate.