[rpm] - avoid division by zero in rpmdb size calculation (#671056) - fix secondary index iteration returin

Panu Matilainen pmatilai at fedoraproject.org
Fri Jan 21 12:07:59 UTC 2011


commit f3f6be5ff38800a7a5b5c69a4da82e6fa4c73f80
Author: Panu Matilainen <pmatilai at redhat.com>
Date:   Fri Jan 21 14:07:30 2011 +0200

    - avoid division by zero in rpmdb size calculation (#671056)
    - fix secondary index iteration returing duplicate at end (#671149)
    - fix rebuilddb creating duplicate indexes for first header

 rpm-4.9.0-beta1-index-iteration.patch |   25 +++++++++++++++++++++++++
 rpm-4.9.0-beta1-index-rebuild.patch   |   30 ++++++++++++++++++++++++++++++
 rpm-4.9.0-beta1-rpmdb-dsi.patch       |   22 ++++++++++++++++++++++
 rpm.spec                              |   13 ++++++++++++-
 4 files changed, 89 insertions(+), 1 deletions(-)
---
diff --git a/rpm-4.9.0-beta1-index-iteration.patch b/rpm-4.9.0-beta1-index-iteration.patch
new file mode 100644
index 0000000..9712ee3
--- /dev/null
+++ b/rpm-4.9.0-beta1-index-iteration.patch
@@ -0,0 +1,25 @@
+commit a3ec6066af23e0c9e0de6160c14cb2a502e8fa89
+Author: Panu Matilainen <pmatilai at redhat.com>
+Date:   Fri Jan 21 13:52:17 2011 +0200
+
+    Fix rpmdb index match iteration termination with NULL keyp (#671149)
+    - When iterating secondary indexes with NULL keyp, the last entry
+      was being returned twice as dbiAppendSet() would get called
+      even when dbiGet() returned non-zero.
+
+diff --git a/lib/rpmdb.c b/lib/rpmdb.c
+index e58de35..dc6d7a7 100644
+--- a/lib/rpmdb.c
++++ b/lib/rpmdb.c
+@@ -2048,10 +2048,9 @@ rpmdbMatchIterator rpmdbInitIterator(rpmdb db, rpmDbiTagVal rpmtag,
+             /* get all entries from index */
+             xx = dbiCopen(dbi, &dbcursor, 0);
+ 
+-            while (rc==0) {
++            while ((rc = dbiGet(dbi, dbcursor, &key, &data, DB_NEXT)) == 0) {
+                 dbiIndexSet newset = NULL;
+ 
+-                rc = dbiGet(dbi, dbcursor, &key, &data, DB_NEXT);
+                 (void) dbt2set(dbi, &data, &newset);
+                 if (set == NULL) {
+                     set = newset;
diff --git a/rpm-4.9.0-beta1-index-rebuild.patch b/rpm-4.9.0-beta1-index-rebuild.patch
new file mode 100644
index 0000000..2b02cbe
--- /dev/null
+++ b/rpm-4.9.0-beta1-index-rebuild.patch
@@ -0,0 +1,30 @@
+commit 5ddb36d2739653ebe50dc39176a9ca43d0555676
+Author: Panu Matilainen <pmatilai at redhat.com>
+Date:   Fri Jan 21 13:43:12 2011 +0200
+
+    Avoid automatic index generation on db rebuild
+    - The rebuild walks through it all anyway, calling buildIndexes()
+      while in middle of db rebuild ends up in first header added
+      twice to indexes
+
+diff --git a/lib/rpmdb.c b/lib/rpmdb.c
+index 02aef4a..e58de35 100644
+--- a/lib/rpmdb.c
++++ b/lib/rpmdb.c
+@@ -157,6 +157,7 @@ static dbiIndex rpmdbOpenIndex(rpmdb db, rpmDbiTagVal rpmtag, int flags)
+     } else {
+ 	db->_dbi[dbix] = dbi;
+ 	int verifyonly = (flags & RPMDB_FLAG_VERIFYONLY);
++	int rebuild = (db->db_flags & RPMDB_FLAG_REBUILD);
+ 	if (dbiType(dbi) == DBI_PRIMARY) {
+ 	    /* Allocate based on max header instance number + some reserve */
+ 	    if (!verifyonly && (db->db_checked == NULL)) {
+@@ -170,7 +171,7 @@ static dbiIndex rpmdbOpenIndex(rpmdb db, rpmDbiTagVal rpmtag, int flags)
+ 		dbSetFSync(db->db_dbenv, 0);
+ 	    }
+ 	} else { /* secondary index */
+-	    if (!verifyonly && (dbiFlags(dbi) & DBI_CREATED)) {
++	    if (!rebuild && !verifyonly && (dbiFlags(dbi) & DBI_CREATED)) {
+ 		rpmlog(RPMLOG_DEBUG, "index %s needs creating\n", dbiName(dbi));
+ 		db->db_buildindex++;
+                 if (db->db_buildindex == 1) {
diff --git a/rpm-4.9.0-beta1-rpmdb-dsi.patch b/rpm-4.9.0-beta1-rpmdb-dsi.patch
new file mode 100644
index 0000000..f99ae23
--- /dev/null
+++ b/rpm-4.9.0-beta1-rpmdb-dsi.patch
@@ -0,0 +1,22 @@
+commit bd96c179b79fce627403804ad6c236c783aca478
+Author: Panu Matilainen <pmatilai at redhat.com>
+Date:   Fri Jan 21 14:02:28 2011 +0200
+
+    Plug potential division by zero in the rpmdb size calculation (RhBug:671056)
+    - This smells like treating the symptom instead of the disease, add
+      a reminder comment to figure out what's going on here...
+
+diff --git a/lib/transaction.c b/lib/transaction.c
+index ed6f738..06e54af 100644
+--- a/lib/transaction.c
++++ b/lib/transaction.c
+@@ -246,7 +246,8 @@ static void rpmtsUpdateDSIrpmDBSize(const rpmte p,
+     rpm_loff_t headerSize;
+     int64_t bneeded;
+ 
+-    if (dsi==NULL) return;
++    /* XXX somehow we can end up here with bsize 0 (RhBug:671056) */
++    if (dsi == NULL || dsi->bsize == 0) return;
+ 
+     headerSize = rpmteHeaderSize(p);
+     bneeded = BLOCK_ROUND(headerSize, dsi->bsize);
diff --git a/rpm.spec b/rpm.spec
index 7288bf3..10744bd 100644
--- a/rpm.spec
+++ b/rpm.spec
@@ -22,7 +22,7 @@
 Summary: The RPM package management system
 Name: rpm
 Version: %{rpmver}
-Release: %{?snapver:0.%{snapver}.}2%{?dist}
+Release: %{?snapver:0.%{snapver}.}3%{?dist}
 Group: System Environment/Base
 Url: http://www.rpm.org/
 Source0: http://rpm.org/releases/rpm-4.8.x/%{name}-%{srcver}.tar.bz2
@@ -42,6 +42,9 @@ Patch4: rpm-4.8.1-use-gpg2.patch
 
 # Patches already in upstream
 Patch100: rpm-4.9.0-beta1-rofs-rpmdb.patch
+Patch101: rpm-4.9.0-beta1-index-rebuild.patch
+Patch102: rpm-4.9.0-beta1-index-iteration.patch
+Patch103: rpm-4.9.0-beta1-rpmdb-dsi.patch
 
 # These are not yet upstream
 Patch301: rpm-4.6.0-niagara.patch
@@ -207,6 +210,9 @@ packages on a system.
 %patch4 -p1 -b .use-gpg2
 
 %patch100 -p1 -b .rofs-rpmdb
+%patch101 -p1 -b .index-rebuild
+%patch102 -p1 -b .index-iteration
+%patch103 -p1 -b .rpmdb-dsi
 
 %patch301 -p1 -b .niagara
 %patch302 -p1 -b .geode
@@ -417,6 +423,11 @@ exit 0
 %doc COPYING doc/librpm/html/*
 
 %changelog
+* Fri Jan 21 2011 Panu Matilainen <pmatilai at redhat.com> - 4.9.0-0.beta1.3
+- avoid division by zero in rpmdb size calculation (#671056)
+- fix secondary index iteration returing duplicate at end (#671149)
+- fix rebuilddb creating duplicate indexes for first header
+
 * Fri Jan 21 2011 Panu Matilainen <pmatilai at redhat.com> - 4.9.0-0.beta1.2
 - permit queries from rpmdb on read-only media (#671200)
 


More information about the scm-commits mailing list