From ac751771745bb1d3c69047fd2352652c81b1c8e4 Mon Sep 17 00:00:00 2001 From: hugel <2712504175@qq.com> Date: Tue, 26 Nov 2024 14:24:45 +0800 Subject: [PATCH] sync patches from upstream (cherry picked from commit 924f1d628a913674a4d0eb2860181f7f0b665129) --- ...-sanity-checks-on-db-add-and-rebuild.patch | 64 +++++++++++++++++++ ...-Fix-a-memory-leak-on-rpmdb-importdb.patch | 27 ++++++++ ...rt-Fix-memleak-when-process-policies.patch | 35 ++++++++++ rpm.spec | 8 ++- ...e-of-python-scripts-from-old-version.patch | 2 +- 5 files changed, 134 insertions(+), 2 deletions(-) create mode 100644 backport-Enforce-the-same-sanity-checks-on-db-add-and-rebuild.patch create mode 100644 backport-Fix-a-memory-leak-on-rpmdb-importdb.patch create mode 100644 backport-Fix-memleak-when-process-policies.patch diff --git a/backport-Enforce-the-same-sanity-checks-on-db-add-and-rebuild.patch b/backport-Enforce-the-same-sanity-checks-on-db-add-and-rebuild.patch new file mode 100644 index 0000000..b9dfbc7 --- /dev/null +++ b/backport-Enforce-the-same-sanity-checks-on-db-add-and-rebuild.patch @@ -0,0 +1,64 @@ +From 1fbf8aeb4e78b8b4afeeaafcbc97b3cbf7cfeaba Mon Sep 17 00:00:00 2001 +From: Panu Matilainen +Date: Tue, 17 Sep 2024 08:31:35 +0300 +Subject: [PATCH] Enforce the same sanity checks on db add and rebuild + +Conflict:adapt context; don't use RPMTAG_HEADERIMMUTABLE because +e484d99 is not merged; use int type instead of bool in validHeader() +Reference:https://github.com/rpm-software-management/rpm/commit/1fbf8aeb4e78b8b4afeeaafcbc97b3cbf7cfeaba + +It doesn't make a whole lot of sense to allow inserting headers +that will get removed as invalid on the next rebuild. Funny what +oddities have survived all this time... + +Fixes: #3306 +--- + lib/rpmdb.c | 18 +++++++++++++----- + 1 file changed, 13 insertions(+), 5 deletions(-) + +diff --git a/lib/rpmdb.c b/lib/rpmdb.c +index 3bf3457f3..dccdf80cd 100644 +--- a/lib/rpmdb.c ++++ b/lib/rpmdb.c +@@ -2176,6 +2176,17 @@ exit: + return (rc == 0) ? RPMRC_OK : RPMRC_FAIL; + } + ++static int validHeader(Header h) ++{ ++ if (!(headerIsEntry(h, RPMTAG_NAME) && ++ headerIsEntry(h, RPMTAG_VERSION) && ++ headerIsEntry(h, RPMTAG_RELEASE))) ++ { ++ return 0; ++ } ++ return 1; ++} ++ + int rpmdbAdd(rpmdb db, Header h) + { + dbiIndex dbi = NULL; +@@ -2189,7 +2200,7 @@ int rpmdbAdd(rpmdb db, Header h) + return 0; + + hdrBlob = headerExport(h, &hdrLen); +- if (hdrBlob == NULL || hdrLen == 0) { ++ if (!validHeader(h) || hdrBlob == NULL || hdrLen == 0) { + ret = -1; + goto exit; + } +@@ -2424,10 +2435,7 @@ int rpmdbRebuild(const char * prefix, rpmts ts, + while ((h = rpmdbNextIterator(mi)) != NULL) { + + /* let's sanity check this record a bit, otherwise just skip it */ +- if (!(headerIsEntry(h, RPMTAG_NAME) && +- headerIsEntry(h, RPMTAG_VERSION) && +- headerIsEntry(h, RPMTAG_RELEASE))) +- { ++ if (!validHeader(h)) { + rpmlog(RPMLOG_ERR, + _("header #%u in the database is bad -- skipping.\n"), + rpmdbGetIteratorOffset(mi)); +-- +2.33.0 + diff --git a/backport-Fix-a-memory-leak-on-rpmdb-importdb.patch b/backport-Fix-a-memory-leak-on-rpmdb-importdb.patch new file mode 100644 index 0000000..cfb07c4 --- /dev/null +++ b/backport-Fix-a-memory-leak-on-rpmdb-importdb.patch @@ -0,0 +1,27 @@ +From 4b830f7b5a4a70a53e2eef63baf82b7fff308a3c Mon Sep 17 00:00:00 2001 +From: Panu Matilainen +Date: Fri, 11 Oct 2024 14:26:57 +0300 +Subject: [PATCH] Fix a memory leak on rpmdb --importdb + +Conflict:modify rpmdb.c instead of tools/rpmdb.cc +Reference:https://github.com/rpm-software-management/rpm/commit/4b830f7b5a4a70a53e2eef63baf82b7fff308a3c + +--- + rpmdb.c | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/rpmdb.c b/rpmdb.c +index 20d5d67bd..1736e1ef7 100644 +--- a/rpmdb.c ++++ b/rpmdb.c +@@ -79,6 +79,7 @@ static int importDB(rpmts ts) + Header h; + while ((h = headerRead(fd, HEADER_MAGIC_YES))) { + rc += rpmtsImportHeader(txn, h, 0); ++ headerFree(h); + } + } else { + rc = -1; +-- +2.33.0 + diff --git a/backport-Fix-memleak-when-process-policies.patch b/backport-Fix-memleak-when-process-policies.patch new file mode 100644 index 0000000..a17506e --- /dev/null +++ b/backport-Fix-memleak-when-process-policies.patch @@ -0,0 +1,35 @@ +From 937e725626eecad2e0c34463e733ae123ba2ff5e Mon Sep 17 00:00:00 2001 +From: xujing +Date: Thu, 12 Sep 2024 20:52:30 +0800 +Subject: [PATCH] Fix memleak when process policies + +Conflict:NA +Reference:https://github.com/rpm-software-management/rpm/commit/937e725626eecad2e0c34463e733ae123ba2ff5e + +--- + build/policies.c | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/build/policies.c b/build/policies.c +index 5d704c0eb..69062ee6a 100644 +--- a/build/policies.c ++++ b/build/policies.c +@@ -289,6 +289,7 @@ static rpmRC processPolicies(rpmSpec spec, Package pkg, int test) + mod = freeModule(mod); + name = _free(name); + types = _free(types); ++ optCon = poptFreeContext(optCon); + } + + rc = RPMRC_OK; +@@ -297,6 +298,7 @@ static rpmRC processPolicies(rpmSpec spec, Package pkg, int test) + freeModule(mod); + free(name); + free(types); ++ poptFreeContext(optCon); + + return rc; + } +-- +2.33.0 + diff --git a/rpm.spec b/rpm.spec index 459f2a0..67f288f 100644 --- a/rpm.spec +++ b/rpm.spec @@ -1,6 +1,6 @@ Name: rpm Version: 4.17.0 -Release: 45 +Release: 46 Summary: RPM Package Manager License: GPLv2+ URL: http://www.rpm.org/ @@ -128,6 +128,9 @@ Patch6096: backport-Fix-potential-use-of-uninitialized-pgp-struct.patch Patch6097: backport-Fix-macro-scoping-level-on-re-entry-from-expresssion.patch Patch6098: backport-Reset-recursion-depth-for-error-message.patch Patch6099: backport-Fix-division-by-zero-in-elfdeps-RhBug-2299414.patch +Patch6100: backport-Fix-memleak-when-process-policies.patch +Patch6101: backport-Enforce-the-same-sanity-checks-on-db-add-and-rebuild.patch +Patch6102: backport-Fix-a-memory-leak-on-rpmdb-importdb.patch BuildRequires: gcc autoconf automake libtool make gawk popt-devel openssl-devel readline-devel BuildRequires: zlib-devel zstd-devel >= 1.3.8 xz-devel bzip2-devel libarchive-devel ima-evm-utils-devel @@ -418,6 +421,9 @@ make check || (cat tests/rpmtests.log; exit 0) %{_mandir}/man1/gendiff.1* %changelog +* Tue Nov 26 2024 hugel - 4.17.0-46 +- sync patches from upstream + * Sat Oct 26 2024 Funda Wang - 4.17.0-45 - fix RPM_LD_FLAGS not got exported diff --git a/still-in-use-of-python-scripts-from-old-version.patch b/still-in-use-of-python-scripts-from-old-version.patch index d9fee0b..30c3c33 100644 --- a/still-in-use-of-python-scripts-from-old-version.patch +++ b/still-in-use-of-python-scripts-from-old-version.patch @@ -117,7 +117,7 @@ index 0000000..d9c4832 +# +# Support this by assuming that below each /usr/lib/python$VERSION/, all +# .pyc/.pyo files are to be compiled for /usr/bin/python$VERSION. -+# ++# +# For example, below /usr/lib/python2.6/, we're targeting /usr/bin/python2.6 +# and below /usr/lib/python3.1/, we're targeting /usr/bin/python3.1 + -- Gitee