diff --git a/backport-Fix-a-memleak-on-invalid-command-line-options.patch b/backport-Fix-a-memleak-on-invalid-command-line-options.patch new file mode 100644 index 0000000..cf8038a --- /dev/null +++ b/backport-Fix-a-memleak-on-invalid-command-line-options.patch @@ -0,0 +1,85 @@ +From 1825dbf8244b129665a69481c4537a57b9e03a8f Mon Sep 17 00:00:00 2001 +From: Panu Matilainen +Date: Wed, 21 Feb 2024 16:07:05 +0200 +Subject: [PATCH] Fix a memleak on invalid command line options + + The OS will clean it up yes, but in the meanwhile ASAN (when enabled) + blew up on your face and scared you silly. Use the opportunity to add a + test for a test on invalid option. + +--- + lib/poptALL.c | 11 ++++++++--- + tests/rpmgeneral.at | 10 +++++++++- + 2 files changed, 17 insertions(+), 4 deletions(-) + +diff --git a/lib/poptALL.c b/lib/poptALL.c +index 0fa1c40..3c4c096 100644 +--- a/lib/poptALL.c ++++ b/lib/poptALL.c +@@ -294,7 +294,7 @@ rpmcliFini(poptContext optCon) + poptContext + rpmcliInit(int argc, char *const argv[], struct poptOption * optionsTable) + { +- poptContext optCon; ++ poptContext optCon = NULL; + int rc; + const char *ctx, *execPath; + +@@ -332,14 +332,14 @@ rpmcliInit(int argc, char *const argv[], struct poptOption * optionsTable) + while ((rc = poptGetNextOpt(optCon)) > 0) { + fprintf(stderr, _("%s: option table misconfigured (%d)\n"), + xgetprogname(), rc); +- exit(EXIT_FAILURE); ++ goto err; + } + + if (rc < -1) { + fprintf(stderr, "%s: %s: %s\n", xgetprogname(), + poptBadOption(optCon, POPT_BADOPTION_NOALIAS), + poptStrerror(rc)); +- exit(EXIT_FAILURE); ++ goto err; + } + + /* Read rpm configuration (if not already read). */ +@@ -351,4 +351,9 @@ rpmcliInit(int argc, char *const argv[], struct poptOption * optionsTable) + } + + return optCon; ++ ++err: ++ poptFreeContext(optCon); ++ exit(EXIT_FAILURE); ++ return NULL; /* not reached */ + } +diff --git a/tests/rpmgeneral.at b/tests/rpmgeneral.at +index 5cbfc23..6d85ace 100644 +--- a/tests/rpmgeneral.at ++++ b/tests/rpmgeneral.at +@@ -26,7 +26,6 @@ AT_CHECK([runroot rpm --version],[0], + ]) + AT_CLEANUP + +- + # ------------------------------ + AT_SETUP([rpmbuild --version]) + AT_KEYWORDS([basic]) +@@ -35,6 +34,15 @@ AT_CHECK([runroot rpmbuild --version],[0], + ]) + AT_CLEANUP + ++AT_SETUP([rpm invalid option]) ++AT_KEYWORDS([basic]) ++AT_CHECK([runroot rpm --badopt], ++[1], ++[], ++[rpm: --badopt: unknown option ++]) ++AT_CLEANUP ++ + # Check that libtool versioning matches expectations, it's easy to screw up. + AT_SETUP([rpm library version]) + AT_KEYWORDS([basic]) +-- +2.33.0 + diff --git a/backport-Let-eBPF-ELF-files-be-packaged-in-noarch-packages.patch b/backport-Let-eBPF-ELF-files-be-packaged-in-noarch-packages.patch new file mode 100644 index 0000000..b05cf19 --- /dev/null +++ b/backport-Let-eBPF-ELF-files-be-packaged-in-noarch-packages.patch @@ -0,0 +1,44 @@ +From 5ece87a250880b08ccecfc5b34986347d8cca843 Mon Sep 17 00:00:00 2001 +From: Panu Matilainen +Date: Thu, 8 Feb 2024 09:44:51 +0200 +Subject: [PATCH] Let eBPF ELF files be packaged in noarch packages + + eBPF ELF represents a virtual machine where our file colors make no + sense at all. Filter out the color from these files to avoid a + "Arch dependent binaries in noarch package" error from them in noarch + packages. + + We don't want to pull in clang to the check images just because of + this, so add a pre-built binary for the check and a simple way to + reproduce from the test-spec. + + Fixes: #2875 + +Reference:https://github.com/rpm-software-management/rpm/commit/5ece87a250880b08ccecfc5b34986347d8cca843 +Conflict:Deleted binary files and test code because it would add clang +Requires. +--- + build/rpmfc.c | 7 +++++++ + 1 file changed, 7 insertions(+) + +diff --git a/build/rpmfc.c b/build/rpmfc.c +index 07171fa..6d40a19 100644 +--- a/build/rpmfc.c ++++ b/build/rpmfc.c +@@ -1151,6 +1151,13 @@ static uint32_t getElfColor(const char *fn) + color = RPMFC_ELF32; + break; + } ++ ++ /* Exceptions to coloring */ ++ switch (ehdr.e_machine) { ++ case EM_BPF: ++ color = 0; ++ break; ++ } + } + if (elf) + elf_end(elf); +-- +2.33.0 + diff --git a/rpm.spec b/rpm.spec index eeeb0fb..3a74880 100644 --- a/rpm.spec +++ b/rpm.spec @@ -1,6 +1,6 @@ Name: rpm Version: 4.17.0 -Release: 34 +Release: 35 Summary: RPM Package Manager License: GPLv2+ URL: http://www.rpm.org/ @@ -118,6 +118,8 @@ Patch6079: backport-Use-unsigned-integers-for-buildtime-too-for-Y2K38-sa.patch Patch6080: backport-Fix-a-theoretical-use-of-uninitialized-struct-member.patch Patch6081: backport-Fix-spec-parser-leaks-from-trans-f-file.patch Patch6082: backport-Tip-toe-around-rpmfiFN-thin-ice-in-fsm.patch +Patch6083: backport-Fix-a-memleak-on-invalid-command-line-options.patch +Patch6084: backport-Let-eBPF-ELF-files-be-packaged-in-noarch-packages.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 @@ -408,6 +410,9 @@ make check || (cat tests/rpmtests.log; exit 0) %{_mandir}/man1/gendiff.1* %changelog +* Mon Mar 25 2024 hongjinghao - 4.17.0-35 +- Fix memleak and let eBPF ELF files be packaged in noarch packages + * Wed Mar 13 2024 gengqihu - 4.17.0-34 - Backport some patches from upstream