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: Upstream fixes for #2360342 and #2362996
Date: Mon, 23 Nov 2026 09:35:58 GMT [thread overview]
Message-ID: <179542655844.1.13724831184645760528.rpms-rpm-8d0ce091b954@fedoraproject.org> (raw)
A new commit has been pushed.
Repo : rpms/rpm
Branch : pmatilai-v6
Commit : 8d0ce091b954a2291ca2560ea829cca1b429674d
Author : Panu Matilainen <pmatilai@redhat.com>
Date : 2025-05-12T09:23:54+03:00
Stats : +269/-3 in 3 file(s)
URL : https://src.fedoraproject.org/rpms/rpm/c/8d0ce091b954a2291ca2560ea829cca1b429674d?branch=pmatilai-v6
Log:
Upstream fixes for #2360342 and #2362996
---
diff --git a/0001-Fix-a-refactoring-regression-in-rich-dep-and-rpmdb-s.patch b/0001-Fix-a-refactoring-regression-in-rich-dep-and-rpmdb-s.patch
new file mode 100644
index 0000000..8fdbda2
--- /dev/null
+++ b/0001-Fix-a-refactoring-regression-in-rich-dep-and-rpmdb-s.patch
@@ -0,0 +1,112 @@
+From a333eaa3f0fbce0c77cea23015144e13d9c039e2 Mon Sep 17 00:00:00 2001
+Message-ID: <a333eaa3f0fbce0c77cea23015144e13d9c039e2.1747030627.git.pmatilai@redhat.com>
+From: Panu Matilainen <pmatilai@redhat.com>
+Date: Wed, 23 Apr 2025 13:03:30 +0300
+Subject: [PATCH] Fix a refactoring regression in rich dep and rpmdb set
+ calculations
+
+Commit 52f311e224254d7cb28bf2ced22db7b50e1a2653 failed to take into
+account that std::set_difference() and std::set_intersection() require
+both data sets to be sorted, whereas the old manual implementation only
+required the second set to be sorted.
+
+Add a minimal testcase for the WITH rich dep case from the original
+report. Technically the same issue could occur with WITHOUT rich
+dependencies and rpmdb lookups through dbiFindMatches() but I don't
+reproducers for those so just fixing the code for the "obvious" error.
+
+I'm not 100% confident this addresses all such assumptions in the
+codebase. dbiIndexSet should really use a data structure that doesn't
+require manual sorting like this, but then that's a much bigger change
+as the rpmdb code is currently accessing the set members via an index...
+
+Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=2360342
+---
+ lib/backend/dbiset.cc | 4 ++++
+ lib/backend/dbiset.hh | 6 ++++--
+ tests/rpmdeps.at | 10 ++++++++--
+ 3 files changed, 16 insertions(+), 4 deletions(-)
+
+diff --git a/lib/backend/dbiset.cc b/lib/backend/dbiset.cc
+index 14b6d7857..e29dfd377 100644
+--- a/lib/backend/dbiset.cc
++++ b/lib/backend/dbiset.cc
+@@ -101,6 +101,8 @@ int dbiIndexSetPruneSet(dbiIndexSet set, dbiIndexSet oset, int sorted)
+ if (set->recs.empty() || oset == NULL || oset->recs.empty())
+ return 1;
+
++ if (set->recs.size() > 1 && !sorted)
++ dbiIndexSetSort(set);
+ if (oset->recs.size() > 1 && !sorted)
+ dbiIndexSetSort(oset);
+
+@@ -120,6 +122,8 @@ int dbiIndexSetFilterSet(dbiIndexSet set, dbiIndexSet oset, int sorted)
+ return num ? 0 : 1;
+ }
+
++ if (set->recs.size() > 1 && !sorted)
++ dbiIndexSetSort(set);
+ if (oset->recs.size() > 1 && !sorted)
+ dbiIndexSetSort(oset);
+
+diff --git a/lib/backend/dbiset.hh b/lib/backend/dbiset.hh
+index fdb28e96d..10d584545 100644
+--- a/lib/backend/dbiset.hh
++++ b/lib/backend/dbiset.hh
+@@ -51,9 +51,10 @@ int dbiIndexSetAppendOne(dbiIndexSet set, unsigned int hdrNum,
+
+ /**
+ * Remove an index set from another.
++ * The sets are sorted as a side-effect if sorted is 0.
+ * @param set set of index database items
+ * @param oset set of entries that should be removed
+- * @param sorted oset is already sorted?
++ * @param sorted are set and oset already sorted?
+ * @return 0 success, 1 failure (no items found)
+ */
+ RPM_GNUC_INTERNAL
+@@ -61,9 +62,10 @@ int dbiIndexSetPruneSet(dbiIndexSet set, dbiIndexSet oset, int sorted);
+
+ /**
+ * Filter (intersect) an index set with another.
++ * The sets are sorted as a side-effect if sorted is 0.
+ * @param set set of index database items
+ * @param oset set of entries that should be intersected
+- * @param sorted oset is already sorted?
++ * @param sorted are set and oset already sorted?
+ * @return 0 success, 1 failure (no items removed)
+ */
+ RPM_GNUC_INTERNAL
+diff --git a/tests/rpmdeps.at b/tests/rpmdeps.at
+index 4aca7168e..469ea04db 100644
+--- a/tests/rpmdeps.at
++++ b/tests/rpmdeps.at
+@@ -327,17 +327,23 @@ AT_KEYWORDS([install, boolean])
+ runroot rpmbuild --quiet -bb \
+ --define "pkg one" \
+ --define "reqs (deptest-two with flavor = desktop)" \
++ --define "provs feat = 4.0" \
+ /data/SPECS/deptest.spec
+
+ runroot rpmbuild --quiet -bb \
+ --define "pkg two" \
+- --define "provs flavor = desktop" \
++ --define "provs flavor = desktop feat = 1.5" \
++ /data/SPECS/deptest.spec
++
++runroot rpmbuild --quiet -bb \
++ --define "pkg three" \
++ --define "reqs (feat >= 1.0 with feat < 3.0)" \
+ /data/SPECS/deptest.spec
+
+ # satisfied WITH require in transaction
+ RPMTEST_CHECK([
+ RPMDB_RESET
+-runroot rpm -U /build/RPMS/noarch/deptest-one-1.0-1.noarch.rpm /build/RPMS/noarch/deptest-two-1.0-1.noarch.rpm
++runroot rpm -U /build/RPMS/noarch/deptest-two-1.0-1.noarch.rpm /build/RPMS/noarch/deptest-three-1.0-1.noarch.rpm /build/RPMS/noarch/deptest-one-1.0-1.noarch.rpm
+ ],
+ [0],
+ [],
+--
+2.49.0
+
diff --git a/0001-Fix-a-regression-when-calling-rpmReadPackageFile-wit.patch b/0001-Fix-a-regression-when-calling-rpmReadPackageFile-wit.patch
new file mode 100644
index 0000000..aead7a0
--- /dev/null
+++ b/0001-Fix-a-regression-when-calling-rpmReadPackageFile-wit.patch
@@ -0,0 +1,151 @@
+From 492ff071da8b3a6b344122206834b68dc49746f3 Mon Sep 17 00:00:00 2001
+Message-ID: <492ff071da8b3a6b344122206834b68dc49746f3.1747030462.git.pmatilai@redhat.com>
+From: Panu Matilainen <pmatilai@redhat.com>
+Date: Wed, 30 Apr 2025 11:42:17 +0300
+Subject: [PATCH] Fix a regression when calling rpmReadPackageFile() with NULL
+ ts
+
+Commit 09510e413dbbdecfa6d65406a31517c79dd6c773 introduced unconditional
+dereferencing of the keyring during verification, and so segfaults on
+NULL keyring. That can't happen within rpm itself, so we need a new
+test program to trigger it: call rpmReadPackageFile() with NULL ts.
+
+Start a new test group of API tests, we'll need to do more of these.
+I wasted an hour or two looking for a way to reproduce this by rpm or
+the python bindings when writing this tiny test-program took all of
+five minutes.
+
+Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=2362996
+
+(tests/CMakeLists.txt is slightly modified from upstream to get it to
+apply)
+
+---
+ rpmio/rpmkeyring.cc | 32 +++++++++++++++++---------------
+ tests/CMakeLists.txt | 5 +++--
+ tests/readpkgnullts.c | 18 ++++++++++++++++++
+ tests/rpmapi.at | 13 +++++++++++++
+ 4 files changed, 51 insertions(+), 17 deletions(-)
+ create mode 100644 tests/readpkgnullts.c
+ create mode 100644 tests/rpmapi.at
+
+diff --git a/rpmio/rpmkeyring.cc b/rpmio/rpmkeyring.cc
+index 7edbf83a7..4853d045c 100644
+--- a/rpmio/rpmkeyring.cc
++++ b/rpmio/rpmkeyring.cc
+@@ -429,27 +429,29 @@ rpmRC rpmKeyringVerifySig2(rpmKeyring keyring, pgpDigParams sig, DIGEST_CTX ctx,
+ rpmPubkey key = NULL;
+
+ if (sig && ctx) {
+- rdlock lock(keyring->mutex);
+- auto keyid = key2str(pgpDigParamsSignID(sig));
+ std::vector<std::pair<int, std::string>> results = {};
++ if (keyring) {
++ auto keyid = key2str(pgpDigParamsSignID(sig));
++ rdlock lock(keyring->mutex);
+
+- /* Look for verifying key */
+- auto range = keyring->keys.equal_range(keyid);
++ /* Look for verifying key */
++ auto range = keyring->keys.equal_range(keyid);
+
+- for (auto it = range.first; it != range.second; ++it) {
+- key = it->second;
++ for (auto it = range.first; it != range.second; ++it) {
++ key = it->second;
+
+- /* Do the parameters match the signature? */
+- if (pgpDigParamsAlgo(sig, PGPVAL_PUBKEYALGO)
+- != pgpDigParamsAlgo(key->pgpkey, PGPVAL_PUBKEYALGO))
+- {
+- continue;
+- }
++ /* Do the parameters match the signature? */
++ if (pgpDigParamsAlgo(sig, PGPVAL_PUBKEYALGO)
++ != pgpDigParamsAlgo(key->pgpkey, PGPVAL_PUBKEYALGO))
++ {
++ continue;
++ }
+
+- rc = pubKeyVerify(key, sig, ctx, results);
++ rc = pubKeyVerify(key, sig, ctx, results);
+
+- if (rc == RPMRC_OK)
+- break;
++ if (rc == RPMRC_OK)
++ break;
++ }
+ }
+
+ /* No key, sanity check signature*/
+diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
+index 3c0066f46..bef9c8bd2 100644
+--- a/tests/CMakeLists.txt
++++ b/tests/CMakeLists.txt
+@@ -28,6 +28,7 @@ set(TESTSUITE_AT
+ rpmgeneral.at
+ rpmvercmp.at
+ rpmmacro.at
++ rpmapi.at
+ rpmdevel.at
+ rpmpython.at
+ rpmdepmatch.at
+@@ -61,10 +62,10 @@ foreach(at ${TESTSUITE_AT})
+ FILE(APPEND ${CMAKE_CURRENT_BINARY_DIR}/rpmtests.at "m4_include([${at}])\n")
+ endforeach()
+
+-set(TESTPROGS rpmpgpcheck rpmpgppubkeyfingerprint)
++set(TESTPROGS rpmpgpcheck rpmpgppubkeyfingerprint readpkgnullts)
+ foreach(prg ${TESTPROGS})
+ add_executable(${prg} EXCLUDE_FROM_ALL ${prg}.c)
+- target_link_libraries(${prg} PRIVATE librpmio)
++ target_link_libraries(${prg} PRIVATE librpm)
+ endforeach()
+ string(REPLACE ";" " " TESTPROG_NAMES "${TESTPROGS}")
+
+diff --git a/tests/readpkgnullts.c b/tests/readpkgnullts.c
+new file mode 100644
+index 000000000..37c464eda
+--- /dev/null
++++ b/tests/readpkgnullts.c
+@@ -0,0 +1,18 @@
++#include <stdio.h>
++#include <rpm/rpmlib.h>
++
++int main(int argc, char *argv[])
++{
++ Header h = NULL;
++ FD_t fd = Fopen(argv[1], "r");
++ int rc = rpmReadPackageFile(NULL, fd, argv[1], &h);
++ if (h != NULL) {
++ char *nevra = headerGetAsString(h, RPMTAG_NEVRA);
++ printf("%s\n", nevra);
++ free(nevra);
++ }
++
++ Fclose(fd);
++ headerFree(h);
++ return rc;
++}
+diff --git a/tests/rpmapi.at b/tests/rpmapi.at
+new file mode 100644
+index 000000000..d8fe1c840
+--- /dev/null
++++ b/tests/rpmapi.at
+@@ -0,0 +1,13 @@
++AT_BANNER([RPM API tests])
++
++RPMTEST_SETUP([[rpmReadPackage() with NULL ts]])
++AT_KEYWORDS([[api signature]])
++RPMTEST_CHECK([[
++readpkgnullts /data/RPMS/hello-2.0-1.x86_64-signed.rpm
++]],
++[4],
++[hello-2.0-1.x86_64
++],
++[warning: /data/RPMS/hello-2.0-1.x86_64-signed.rpm: Header OpenPGP V4 RSA/SHA256 signature, key ID 4344591e1964c5fc: NOKEY
++])
++RPMTEST_CLEANUP
+--
+2.49.0
+
diff --git a/rpm.spec b/rpm.spec
index 5c66772..22d7f9d 100644
--- a/rpm.spec
+++ b/rpm.spec
@@ -24,7 +24,7 @@
%global rpmver 5.99.90
#global snapver rc1
-%global baserelease 4
+%global baserelease 5
%global sover 10
%global srcver %{rpmver}%{?snapver:-%{snapver}}
@@ -119,9 +119,9 @@ rpm-4.20-sysusers.patch
# https://src.fedoraproject.org/rpms/redhat-rpm-config/pull-request/298
0001-Revert-Add-a-deprecation-warning-for-clamp_mtime_to_.patch
-0001-Revert-Replace-dbiset-internals-with-STL-vector-algo.patch
-
# Patches already upstream:
+0001-Fix-a-refactoring-regression-in-rich-dep-and-rpmdb-s.patch
+0001-Fix-a-regression-when-calling-rpmReadPackageFile-wit.patch
# These are not yet upstream
rpm-4.7.1-geode-i686.patch
@@ -617,6 +617,9 @@ fi
%doc %{_defaultdocdir}/rpm/API/
%changelog
+* Mon May 12 2025 Panu Matilainen <pmatilai@redhat.com> - 5.99.90-5
+- Upstream fixes for #2360342 and #2362996
+
* Mon Apr 28 2025 Panu Matilainen <pmatilai@redhat.com> - 5.99.90-4
- Drop no longer needed LTO hack for #2356219
reply other threads:[~2026-11-23 9:35 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=179542655844.1.13724831184645760528.rpms-rpm-8d0ce091b954@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