From 3e84fc0126ecdd5e04e38f23cd5b101112967302 Mon Sep 17 00:00:00 2001 From: Roberto Sassu Date: Tue, 2 Mar 2021 17:58:53 +0100 Subject: [PATCH] Fix digest_list_counter and check rpm_parser --- check_rpm_parser.patch | 21 ++++++++++++++ fix_digest_list_counter.patch | 53 +++++++++++++++++++++++++++++++++++ rpm.spec | 10 ++++++- 3 files changed, 83 insertions(+), 1 deletion(-) create mode 100644 check_rpm_parser.patch create mode 100644 fix_digest_list_counter.patch diff --git a/check_rpm_parser.patch b/check_rpm_parser.patch new file mode 100644 index 0000000..88d78fe --- /dev/null +++ b/check_rpm_parser.patch @@ -0,0 +1,21 @@ +diff -uprN rpm-4.15.1.orig/plugins/digest_list.c rpm-4.15.1/plugins/digest_list.c +--- rpm-4.15.1.orig/plugins/digest_list.c 2021-03-03 09:29:59.621126068 +0100 ++++ rpm-4.15.1/plugins/digest_list.c 2021-03-03 09:30:51.584057644 +0100 +@@ -524,6 +524,7 @@ static rpmRC digest_list_file_common(rpm + rpmFsmOp op, int pre, int res) + { + rpmFileAction action = XFO_ACTION(op); ++ struct stat st; + + if (!digest_list_counter) + return RPMRC_OK; +@@ -552,6 +553,9 @@ static rpmRC digest_list_file_common(rpm + return RPMRC_OK; + } + ++ if (stat(RPM_PARSER, &st) == -1) ++ return RPMRC_OK; ++ + process_digest_list(cur_te, 0); + if (!strcmp(rpmteN(cur_te), "digest-list-tools")) + process_digest_list(cur_te, 1); diff --git a/fix_digest_list_counter.patch b/fix_digest_list_counter.patch new file mode 100644 index 0000000..4aa0c6b --- /dev/null +++ b/fix_digest_list_counter.patch @@ -0,0 +1,53 @@ +diff -uprN rpm-4.15.1.orig/plugins/digest_list.c rpm-4.15.1/plugins/digest_list.c +--- rpm-4.15.1.orig/plugins/digest_list.c 2021-03-01 18:47:06.480623807 +0100 ++++ rpm-4.15.1/plugins/digest_list.c 2021-03-02 17:21:14.392456682 +0100 +@@ -485,8 +485,8 @@ int digest_list_counter; + static rpmRC digest_list_psm_pre(rpmPlugin plugin, rpmte te) + { + Header rpm = rpmteHeader(te); +- rpmtd dirnames; +- int i; ++ rpmtd dirnames, dirindexes; ++ int i = -1; + + digest_list_counter = 0; + +@@ -495,13 +495,26 @@ static rpmRC digest_list_psm_pre(rpmPlug + + while ((i = rpmtdNext(dirnames)) >= 0) { + char *dirname = (char *) rpmtdGetString(dirnames); ++ + if (!strncmp(dirname, DIGEST_LIST_DEFAULT_PATH, +- sizeof(DIGEST_LIST_DEFAULT_PATH) - 1)) +- digest_list_counter++; ++ sizeof(DIGEST_LIST_DEFAULT_PATH) - 1) && ++ dirname[sizeof(DIGEST_LIST_DEFAULT_PATH) - 1] == '/') ++ break; + } + + rpmtdFree(dirnames); + ++ if (i == -1) ++ return RPMRC_OK; ++ ++ dirindexes = rpmtdNew(); ++ headerGet(rpm, RPMTAG_DIRINDEXES, dirindexes, 0); ++ while (rpmtdNext(dirindexes) >= 0) ++ if (rpmtdGetNumber(dirindexes) == i) ++ digest_list_counter++; ++ ++ rpmtdFree(dirindexes); ++ + cur_te = te; + return RPMRC_OK; + } +@@ -528,7 +541,8 @@ static rpmRC digest_list_file_common(rpm + if (digest_list_counter) { + if (!pre) { + if (!strncmp(path, DIGEST_LIST_DEFAULT_PATH, +- sizeof(DIGEST_LIST_DEFAULT_PATH) - 1)) ++ sizeof(DIGEST_LIST_DEFAULT_PATH) - 1) && ++ path[sizeof(DIGEST_LIST_DEFAULT_PATH) - 1] == '/') + digest_list_counter--; + } else { + digest_list_counter = 0; diff --git a/rpm.spec b/rpm.spec index ed0d2e6..f9f35c2 100644 --- a/rpm.spec +++ b/rpm.spec @@ -1,6 +1,6 @@ Name: rpm Version: 4.15.1 -Release: 21 +Release: 22 Summary: RPM Package Manager License: GPLv2+ URL: http://www.rpm.org/ @@ -48,6 +48,8 @@ Patch37: backport-Fix-possible-read-beyond-buffer-in-rstrnlenhash.patch Patch38: backport-Make-fdSeek-return-0-on-success-1-on-error.patch Patch39: backport-Fix-logic-error-in-grabArgs.patch Patch40: backport-Use-libelf-for-determining-file-colors.patch +Patch41: fix_digest_list_counter.patch +Patch42: check_rpm_parser.patch BuildRequires: gcc autoconf automake libtool make gawk popt-devel openssl-devel readline-devel libdb-devel BuildRequires: zlib-devel libzstd-devel xz-devel bzip2-devel libarchive-devel ima-evm-utils-devel @@ -296,6 +298,12 @@ make check || (cat tests/rpmtests.log; exit 0) %{_mandir}/man1/gendiff.1* %changelog +* Tue Mar 02 2021 Roberto Sassu - 4.15.1-22 +- Type:bugfix +- ID:NA +- SUG:NA +- DESC:fix digest_list_counter and check rpm_parser + * Mon Jan 11 2021 Liquor - 4.15.1-21 - Type:enhancement - ID:NA -- Gitee