代码拉取完成,页面将自动刷新
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
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。