public inbox for git-commits@fedoraproject.org
help / color / mirror / Atom feed
From: Panu Matilainen <pmatilai@redhat.com>
To: git-commits@fedoraproject.org
Subject: [rpms/rpm] pmatilai-v6: - avoid division by zero in rpmdb size calculation (#671056)
Date: Mon, 23 Nov 2026 09:26:52 GMT [thread overview]
Message-ID: <179542601211.1.14178588716799316688.rpms-rpm-f3f6be5ff388@fedoraproject.org> (raw)
A new commit has been pushed.
Repo : rpms/rpm
Branch : pmatilai-v6
Commit : f3f6be5ff38800a7a5b5c69a4da82e6fa4c73f80
Author : Panu Matilainen <pmatilai@redhat.com>
Date : 2011-01-21T14:07:30+02:00
Stats : +89/-1 in 4 file(s)
URL : https://src.fedoraproject.org/rpms/rpm/c/f3f6be5ff38800a7a5b5c69a4da82e6fa4c73f80?branch=pmatilai-v6
Log:
- 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
---
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@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@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@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@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@redhat.com> - 4.9.0-0.beta1.2
- permit queries from rpmdb on read-only media (#671200)
reply other threads:[~2026-11-23 9:26 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=179542601211.1.14178588716799316688.rpms-rpm-f3f6be5ff388@fedoraproject.org \
--to=pmatilai@redhat.com \
--cc=git-commits@fedoraproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox