!428 [sync] PR-425: sync patches from upstream

From: @openeuler-sync-bot 
Reviewed-by: @xujing99 
Signed-off-by: @xujing99
This commit is contained in:
openeuler-ci-bot 2024-11-26 11:03:28 +00:00 committed by Gitee
commit 91a6e89d80
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
5 changed files with 134 additions and 2 deletions

View File

@ -0,0 +1,64 @@
From 1fbf8aeb4e78b8b4afeeaafcbc97b3cbf7cfeaba Mon Sep 17 00:00:00 2001
From: Panu Matilainen <pmatilai@redhat.com>
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

View File

@ -0,0 +1,27 @@
From 4b830f7b5a4a70a53e2eef63baf82b7fff308a3c Mon Sep 17 00:00:00 2001
From: Panu Matilainen <pmatilai@redhat.com>
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

View File

@ -0,0 +1,35 @@
From 937e725626eecad2e0c34463e733ae123ba2ff5e Mon Sep 17 00:00:00 2001
From: xujing <xujing125@huawei.com>
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

View File

@ -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<gengqihu2@h-partners.com> - 4.17.0-46
- sync patches from upstream
* Sat Oct 26 2024 Funda Wang <fundawang@yeah.net> - 4.17.0-45
- fix RPM_LD_FLAGS not got exported

View File

@ -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
+