public inbox for git-commits@fedoraproject.org
help / color / mirror / Atom feed
* [rpms/python3-rpm] epel9: Merge epel9-next into epel9
@ 2026-11-13 18:33 
  0 siblings, 0 replies; 2+ messages in thread
From:  @ 2026-11-13 18:33 UTC (permalink / raw)
  To: git-commits

A new commit has been pushed.

Repo   : rpms/python3-rpm
Branch : epel9
Commit : d5003bf3a04d13fcf03c4228547abae247dd7e5c
Author : Miro Hrončok <miro@hroncok.cz>
Date   : 2026-11-13T17:48:35+01:00
Stats  : +660/-2 in 6 file(s)
URL    : https://src.fedoraproject.org/rpms/python3-rpm/c/d5003bf3a04d13fcf03c4228547abae247dd7e5c?branch=epel9

Log:
Merge epel9-next into epel9

---
diff --git a/0001-Extract-archiver-detection-out-of-doUncompress.patch b/0001-Extract-archiver-detection-out-of-doUncompress.patch
new file mode 100644
index 0000000..ad499b0
--- /dev/null
+++ b/0001-Extract-archiver-detection-out-of-doUncompress.patch
@@ -0,0 +1,143 @@
+From 7aabd4c44b5cf015ac3854cc16fc23e23a87f224 Mon Sep 17 00:00:00 2001
+From: Michal Domonkos <mdomonko@redhat.com>
+Date: Fri, 23 Oct 2026 14:01:04 +0200
+Subject: [PATCH 1/3] Extract archiver detection out of doUncompress()
+
+Move the logic to determine the command line string to an internal macro
+API function called rpmGetArchiver(). This will be needed in the
+subsequent commit.
+
+No functional change.
+---
+ rpmio/macro.c             | 82 +++++++++++++++++++++++----------------
+ rpmio/rpmmacro_internal.h |  8 ++++
+ 2 files changed, 57 insertions(+), 33 deletions(-)
+
+diff --git a/rpmio/macro.c b/rpmio/macro.c
+index 490bf9a6a..6eef3cd2f 100644
+--- a/rpmio/macro.c
++++ b/rpmio/macro.c
+@@ -1107,7 +1107,7 @@ doSP(MacroBuf mb, int chkexist, int negate,
+ static void doUncompress(MacroBuf mb, int chkexist, int negate,
+ 		const char * f, size_t fn, const char * g, size_t gn)
+ {
+-    rpmCompressedMagic compressed = COMPRESSED_OTHER;
++    const char *cmd = NULL;
+     char *b, *be, *buf = NULL;
+     int c;
+ 
+@@ -1123,40 +1123,10 @@ static void doUncompress(MacroBuf mb, int chkexist, int negate,
+     if (gn == 0 || *b == '\0')
+ 	goto exit;
+ 
+-    if (rpmFileIsCompressed(b, &compressed))
++    if (rpmGetArchiver(b, &cmd))
+ 	mb->error = 1;
+ 
+-    switch (compressed) {
+-    default:
+-    case COMPRESSED_NOT:
+-	expandMacro(mb, "%__cat ", 0);
+-	break;
+-    case COMPRESSED_OTHER:
+-	expandMacro(mb, "%__gzip -dc ", 0);
+-	break;
+-    case COMPRESSED_BZIP2:
+-	expandMacro(mb, "%__bzip2 -dc ", 0);
+-	break;
+-    case COMPRESSED_ZIP:
+-	expandMacro(mb, "%__unzip ", 0);
+-	break;
+-    case COMPRESSED_LZMA:
+-    case COMPRESSED_XZ:
+-	expandMacro(mb, "%__xz -dc ", 0);
+-	break;
+-    case COMPRESSED_LZIP:
+-	expandMacro(mb, "%__lzip -dc ", 0);
+-	break;
+-    case COMPRESSED_LRZIP:
+-	expandMacro(mb, "%__lrzip -dqo- ", 0);
+-	break;
+-    case COMPRESSED_7ZIP:
+-	expandMacro(mb, "%__7zip x ", 0);
+-	break;
+-    case COMPRESSED_ZSTD:
+-	expandMacro(mb, "%__zstd -dc ", 0);
+-	break;
+-    }
++    expandMacro(mb, cmd, 0);
+     mbAppendStr(mb, buf);
+ 
+ exit:
+@@ -2004,3 +1974,49 @@ rpmExpandNumeric(const char *arg)
+ 
+     return rc;
+ }
++
++int
++rpmGetArchiver(const char *fn, const char **cmd)
++{
++    int rc = 0;
++    rpmCompressedMagic compressed = COMPRESSED_OTHER;
++    const char *s = NULL;
++
++    if (rpmFileIsCompressed(fn, &compressed))
++	rc = 1;
++
++    switch (compressed) {
++    default:
++    case COMPRESSED_NOT:
++	s = "%__cat ";
++	break;
++    case COMPRESSED_OTHER:
++	s = "%__gzip -dc ";
++	break;
++    case COMPRESSED_BZIP2:
++	s = "%__bzip2 -dc ";
++	break;
++    case COMPRESSED_ZIP:
++	s = "%__unzip ";
++	break;
++    case COMPRESSED_LZMA:
++    case COMPRESSED_XZ:
++	s = "%__xz -dc ";
++	break;
++    case COMPRESSED_LZIP:
++	s = "%__lzip -dc ";
++	break;
++    case COMPRESSED_LRZIP:
++	s = "%__lrzip -dqo- ";
++	break;
++    case COMPRESSED_7ZIP:
++	s = "%__7zip x ";
++	break;
++    case COMPRESSED_ZSTD:
++	s = "%__zstd -dc ";
++	break;
++    }
++
++    *cmd = s;
++    return rc;
++}
+diff --git a/rpmio/rpmmacro_internal.h b/rpmio/rpmmacro_internal.h
+index a59671be8..eca7511da 100644
+--- a/rpmio/rpmmacro_internal.h
++++ b/rpmio/rpmmacro_internal.h
+@@ -19,6 +19,14 @@ extern "C" {
+ RPM_GNUC_INTERNAL
+ const char *findMacroEnd(const char *str);
+ 
++/** \ingroup rpmmacro
++ * Return a command line (without fn) for extracting the archive fn.
++ * Always returns a command line, even on failure.
++ * @param fn		filename of the archive
++ * @retval cmd		command line (with a trailing space)
++ * @return		0 on success, 1 on failure
++ */
++int rpmGetArchiver(const char *fn, const char **cmd);
+ 
+ #ifdef __cplusplus
+ }
+-- 
+2.56.0
+

diff --git a/0001-Fix-rpopen-rpclose-and-make-them-more-POSIXy.patch b/0001-Fix-rpopen-rpclose-and-make-them-more-POSIXy.patch
new file mode 100644
index 0000000..2028741
--- /dev/null
+++ b/0001-Fix-rpopen-rpclose-and-make-them-more-POSIXy.patch
@@ -0,0 +1,153 @@
+From c745bd8ee4b383897927eb2e504dba9b97aa7b03 Mon Sep 17 00:00:00 2001
+From: Michal Domonkos <mdomonko@redhat.com>
+Date: Tue, 3 Nov 2026 08:48:11 +0100
+Subject: [PATCH] Fix rpopen()/rpclose() and make them more POSIXy
+
+Commit 7a4111bc5db4053e5381b65306903837763e7f11 introduced this new pair
+of drop-in replacements for popen()/pclose() but did so somewhat poorly.
+Apart from obvious bugs, there are various less obvious issues that make
+the functions ever so slightly not POSIX conforming. We are not shipping
+them in a generic library, obviously, but the internal callers that used
+to call the original functions could, at least in theory, be affected in
+some unexpected ways and cause regressions.
+
+Namely, the following issues were found:
+
+- rpclose() returned the extracted exit status from the child instead of
+  the original status from waitpid(2), which caused a child exit status
+  of 128 to be considered a "success" in rpmuncompress, oops
+- rpclose() waited on any child, not just the one spawned with rpopen()
+- EINTR wasn't ignored while busy waiting in rpclose()
+- pipe ends weren't always closed in case of failures
+- rpclose() only closed the stream after waiting on the child
+- the child didn't return 127 if the shell couldn't be invoked
+- the shell command didn't use -- to signal the end of options
+
+Fix the issues, and while at it, name the FILE pointer "fp" rather than
+"stream" and use do-while rather than while, for better consistency with
+the existing code as well as readability. Also do some refactoring there
+and add a couple of comments.
+
+Related: CVE-2026-84837, CVE-2026-84838
+Fixes: #4385
+(cherry picked from commit b9127abde15ec1a5d936891f7d5f78ddc5b689ff)
+---
+ cliutils.c | 58 ++++++++++++++++++++++++++++++++----------------------
+ cliutils.h |  2 +-
+ 2 files changed, 36 insertions(+), 24 deletions(-)
+
+diff --git a/cliutils.c b/cliutils.c
+index 6547e7bdb..5edb9fea7 100644
+--- a/cliutils.c
++++ b/cliutils.c
+@@ -14,6 +14,7 @@
+ #include "debug.h"
+ 
+ static pid_t pipeChild = 0;
++static pid_t rpopenChild = 0;
+ 
+ RPM_GNUC_NORETURN
+ void argerror(const char * desc)
+@@ -89,53 +90,64 @@ int finishPipe(void)
+ 
+ FILE* rpopen(const char *cmd, const char *arg, ...)
+ {
+-    FILE *stream = NULL;
++    FILE *fp = NULL;
++    int pipefd[2];
+     ARGV_t argv = NULL;
+     va_list ap;
+-    int pipefd[2];
+-    pid_t pid;
+ 
+     if (pipe(pipefd) < 0)
+-	goto exit;
++	return NULL;
++
++    if ((fp = fdopen(pipefd[0], "r")) == NULL) {
++	close(pipefd[0]);
++	close(pipefd[1]);
++	return NULL;
++    }
+ 
+     argvAdd(&argv, "/bin/sh");
+     argvAdd(&argv, "-c");
+-    argvAdd(&argv, cmd);
+-    argvAdd(&argv, "sh");
++    argvAdd(&argv, "--");
++    argvAdd(&argv, cmd);    /* User command */
++    argvAdd(&argv, "sh");   /* Shell name ($0) */
+ 
++    /* User positional parameters ($1, $2, ...) */
+     va_start(ap, arg);
+     for (const char *s = arg; s != NULL; s = va_arg(ap, const char *))
+ 	argvAdd(&argv, s);
+     va_end(ap);
+ 
+-    if ((pid = fork()) == 0) {
++    if ((rpopenChild = fork()) == 0) {
+ 	dup2(pipefd[1], STDOUT_FILENO);
++	close(pipefd[1]);
+ 	close(pipefd[0]);
+ 	execv(argv[0], argv);
+-	_exit(EXIT_FAILURE);
+-    } else if (pid == -1) {
+-	goto exit;
++	_exit(127);
++    } else if (rpopenChild == -1) {
++	fclose(fp);
++	fp = NULL;
+     }
+ 
+     close(pipefd[1]);
+-    stream = fdopen(pipefd[0], "r");
+-
+-exit:
+     argvFree(argv);
+-    return stream;
++
++    return fp;
+ }
+ 
+-int rpclose(FILE *stream)
++int rpclose(FILE *fp)
+ {
+-    int rc = -1;
+-    int status;
++    int status = -1;
++    pid_t reaped;
+ 
+-    if ((waitpid(-1, &status, 0) == -1) || !WIFEXITED(status))
+-	goto exit;
++    if (rpopenChild <= 0)
++	return -1;
+ 
+-    rc = WEXITSTATUS(status);
++    fclose(fp);
++    do {
++	reaped = waitpid(rpopenChild, &status, 0);
++    } while (reaped == -1 && errno == EINTR);
+ 
+-exit:
+-    fclose(stream);
+-    return rc;
++    if (reaped == -1)
++	return -1;
++
++    return status;
+ }
+diff --git a/cliutils.h b/cliutils.h
+index 4aee1ae72..600ccfa95 100644
+--- a/cliutils.h
++++ b/cliutils.h
+@@ -28,6 +28,6 @@ int finishPipe(void);
+  * $2, and so on.
+  */
+ FILE *rpopen(const char *cmd, const char *arg, ...) RPM_GNUC_NULL_TERMINATED;
+-int rpclose(FILE *stream);
++int rpclose(FILE *fp);
+ 
+ #endif /* _CLIUTIL_H */
+-- 
+2.56.0
+

diff --git a/0001-Prevent-command-injection-via-rpmbuild-t.patch b/0001-Prevent-command-injection-via-rpmbuild-t.patch
new file mode 100644
index 0000000..e4455d2
--- /dev/null
+++ b/0001-Prevent-command-injection-via-rpmbuild-t.patch
@@ -0,0 +1,79 @@
+From 9aa517baeceec55c02678c7bf89713448dd70bb6 Mon Sep 17 00:00:00 2001
+From: Michal Domonkos <mdomonko@redhat.com>
+Date: Wed, 26 Aug 2026 10:53:12 +0200
+Subject: [PATCH] Prevent command injection via rpmbuild -t
+
+When running in -t mode, the spec member name in the passed tarball will
+get macro-expanded twice: first when constructing the target filename in
+getTarSpec() and then in parseSpec(). This allows a crafted tarball to
+execute arbitrary code when the user just runs rpmbuild -ts or similar.
+
+Luckily, neither of these expansions is necessary, they are only done as
+a convenience and/or historical artifact. The former in getTarSpec() was
+only added recently via commit dfffedb5ebe46e039c0313b3d2fb939dfc63efd6
+and can easily be split into a basename(3) call so that the member name
+is not included in the expansion, effectively reverting that part of the
+original commit. The latter seems to be only used as a way to normalize
+the spec filename stored in the rpmSpec struct and can be replaced by a
+mere rpmCleanPath().
+
+Make both changes, and add a corresponding test, too.
+
+Fixes: CVE-2026-78367, #4314
+(backported from commit 2a11eb3e4e51094082e0123aebd797ec051dc094)
+---
+ build/parseSpec.c | 2 +-
+ rpmbuild.c        | 9 +++++++--
+ 2 files changed, 8 insertions(+), 3 deletions(-)
+
+diff --git a/build/parseSpec.c b/build/parseSpec.c
+index 2fd29e178..4d62c337c 100644
+--- a/build/parseSpec.c
++++ b/build/parseSpec.c
+@@ -895,7 +895,7 @@ static rpmSpec parseSpec(const char *specFile, rpmSpecFlags flags,
+     /* Set up a new Spec structure with no packages. */
+     spec = newSpec();
+ 
+-    spec->specFile = rpmGetPath(specFile, NULL);
++    spec->specFile = rpmCleanPath(xstrdup(specFile));
+     pushOFI(spec, spec->specFile);
+     /* If buildRoot not specified, use default %{buildroot} */
+     if (buildRoot) {
+diff --git a/rpmbuild.c b/rpmbuild.c
+index d02caa511..8dbd06d5f 100644
+--- a/rpmbuild.c
++++ b/rpmbuild.c
+@@ -337,6 +337,8 @@ static int isSpecFile(const char * specfile)
+ static char * getTarSpec(const char *arg)
+ {
+     char *specFile = NULL;
++    char *specDir = NULL;
++    char *specBase = NULL;
+     char *specFinal = NULL;
+     const char **spec;
+     char tarbuf[BUFSIZ];
+@@ -386,9 +388,11 @@ static char * getTarSpec(const char *arg)
+     if (!gotspec) {
+     	rpmlog(RPMLOG_ERR, _("Failed to read spec file from %s\n"), arg);
+     } else {
++	specDir = rpmExpand("%{_specdir}", NULL);
++	specBase = basename(tarbuf);
+ 	/* remove trailing \n */
+-	tarbuf[strlen(tarbuf)-1] = '\0';
+-	specFinal = rpmExpand("%{_specdir}/%{basename:", tarbuf, "}", NULL);
++	specBase[strlen(specBase)-1] = '\0';
++	rasprintf(&specFinal, "%s/%s", specDir, specBase);
+ 	if (rename(specFile, specFinal)) {
+ 	    rpmlog(RPMLOG_ERR, _("Failed to rename %s to %s: %m\n"),
+ 		    specFile, specFinal);
+@@ -399,6 +403,7 @@ static char * getTarSpec(const char *arg)
+ 
+ exit:
+     free(specFile);
++    free(specDir);
+     Fclose(fd);
+     return specFinal;
+ }
+-- 
+2.56.0
+

diff --git a/0002-Prevent-command-injection-via-rpmbuild-t-filename.patch b/0002-Prevent-command-injection-via-rpmbuild-t-filename.patch
new file mode 100644
index 0000000..09a6b8c
--- /dev/null
+++ b/0002-Prevent-command-injection-via-rpmbuild-t-filename.patch
@@ -0,0 +1,187 @@
+From b51759c2ec195c3eaab2b0de0b7a60a4512a984e Mon Sep 17 00:00:00 2001
+From: Michal Domonkos <mdomonko@redhat.com>
+Date: Mon, 7 Sep 2026 14:41:39 +0200
+Subject: [PATCH 2/3] Prevent command injection via rpmbuild -t filename
+
+Commit 2a11eb3e4e51094082e0123aebd797ec051dc094 fixed command injection
+via spec file entries, but there's another case where we pass some data
+controlled by the tarball through macro or shell expansion: the filename
+argument itself.
+
+This happens in three places during tarball decompression: the first two
+are in getTarSpec() where we construct and execute the shell command for
+spec file extraction using rpmExpand() and popen(3), respectively, which
+leads to the third one where we execute the actual decompression utility
+using popen(3) in rpmuncompress. The filename gets passed through all of
+these steps, and can cause arbitrary shell code execution in each one.
+
+Fix that by passing the filename as a positional argument when invoking
+the shell so that the command can reference it through the hardcoded $1
+parameter instead of the filename directly. Add our own popen(3) version
+for this purpose that takes an additional argument to be passed as $1 to
+the shell, to preserve the surrounding logic and keep the patch minimal.
+Hardcode /bin/sh as the shell since that's what popen(3) claims to do.
+
+Don't bother with write mode support like the original function, though,
+it can always be added later if this new version turns out to be useful
+elsewhere. Add also a pclose(3) equivalent, just for consistency, since
+the original call would probably work fine when passed the FILE stream
+created by us.
+
+Adjust the rpmuncompress output when in verbose/dry mode so that it is
+preserved exactly. That means, generate the shell command again but this
+time with the actual filename (enclosed in single quotes), and use that
+for printing. Note that this has to happen in *addition* to the default
+command that uses $1 since we need both variants when in verbose mode.
+
+Enable the tests added in the previous commit as they are now expected
+to pass.
+
+Long-term, a better solution would be to split the shell commands such
+that the simple program invocations that need the filename can be done
+with a plain fork-exec instead of popen(3), or better yet, to just port
+the internals to libarchive. But either is much more complex and would
+make the patch more difficult to backport, so let's just stick with the
+uglier fix for now.
+
+Fixes: CVE-2026-84837, CVE-2026-84838
+
+Backported from commit 7a4111bc5db4053e5381b65306903837763e7f11:
+
+- This codebase is only affected by CVE-2026-84837 (rpmbuild -ts), that
+  is, in the getTarSpec() function, since the rpmuncompress utility
+  isn't present yet.
+
+- Obtain the uncompress command line separately by using the newly added
+  rpmGetArchiver() function. This is needed in order to prevent the
+  macro injection flaw since the %{uncompress} macro also does the
+  detection (and thus requires an actual filename on disk to open),
+  unlike in the later versions where it merely expands to the
+  rpmuncompress path.
+
+- Log a warning (but don't fail) if the archiver couldn't be detected:
+  this would have previously generated an empty command when using the
+  %{uncompress} macro, so it's a nice bonus.
+---
+ cliutils.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++
+ cliutils.h |  7 +++++++
+ rpmbuild.c | 12 +++++++++---
+ 3 files changed, 64 insertions(+), 3 deletions(-)
+
+diff --git a/cliutils.c b/cliutils.c
+index 772a105ec..2231ed1f1 100644
+--- a/cliutils.c
++++ b/cliutils.c
+@@ -86,3 +86,51 @@ int finishPipe(void)
+     }
+     return rc;
+ }
++
++FILE* rpopen(const char *cmd, const char *arg)
++{
++    FILE *stream = NULL;
++    ARGV_t argv = NULL;
++    int pipefd[2];
++    pid_t pid;
++
++    if (pipe(pipefd) < 0)
++	goto exit;
++
++    argvAdd(&argv, "/bin/sh");
++    argvAdd(&argv, "-c");
++    argvAdd(&argv, cmd);
++    argvAdd(&argv, "sh");
++    argvAdd(&argv, arg);
++
++    if ((pid = fork()) == 0) {
++	dup2(pipefd[1], STDOUT_FILENO);
++	close(pipefd[0]);
++	execv(argv[0], argv);
++	_exit(EXIT_FAILURE);
++    } else if (pid == -1) {
++	goto exit;
++    }
++
++    close(pipefd[1]);
++    stream = fdopen(pipefd[0], "r");
++
++exit:
++    argvFree(argv);
++    return stream;
++}
++
++int rpclose(FILE *stream)
++{
++    int rc = -1;
++    int status;
++
++    if ((waitpid(-1, &status, 0) == -1) || !WIFEXITED(status))
++	goto exit;
++
++    rc = WEXITSTATUS(status);
++
++exit:
++    fclose(stream);
++    return rc;
++}
+diff --git a/cliutils.h b/cliutils.h
+index b5deee1ba..cda4bebdf 100644
+--- a/cliutils.h
++++ b/cliutils.h
+@@ -22,4 +22,11 @@ int initPipe(void);
+ 
+ int finishPipe(void);
+ 
++/*
++ * A safe, read-only variant of popen(3) that passes untrusted input (arg) as a
++ * positional argument to sh(1) where the command (cmd) can read it via $1.
++ */
++FILE *rpopen(const char *cmd, const char *arg);
++int rpclose(FILE *stream);
++
+ #endif /* _CLIUTIL_H */
+diff --git a/rpmbuild.c b/rpmbuild.c
+index 8dbd06d5f..ddc1e0750 100644
+--- a/rpmbuild.c
++++ b/rpmbuild.c
+@@ -15,6 +15,7 @@
+ #include "lib/signature.h"
+ #include "cliutils.h"
+ 
++#include "rpmio/rpmmacro_internal.h"
+ #include "debug.h"
+ 
+ static struct rpmBuildArguments_s rpmBTArgs;
+@@ -353,13 +354,18 @@ static char * getTarSpec(const char *arg)
+     for (spec = tryspec; *spec != NULL; spec++) {
+ 	FILE *fp;
+ 	char *cmd;
++	const char *uncmd = NULL;
+ 	int specfiles = 0;
+ 
+-	cmd = rpmExpand("%{uncompress: ", arg, "} | ",
++	if (rpmGetArchiver(arg, &uncmd))
++	    rpmlog(RPMLOG_WARNING,
++		    _("Failed to detect archive type: %s\n"), arg);
++
++	cmd = rpmExpand(uncmd, "\"$1\" | ",
+ 			"%{__tar} xOvof - --wildcards ", *spec,
+ 			" 2>&1 > ", specFile, NULL);
+ 
+-	if (!(fp = popen(cmd, "r"))) {
++	if (!(fp = rpopen(cmd, arg))) {
+ 	    rpmlog(RPMLOG_ERR, _("Failed to open tar pipe: %m\n"));
+ 	} else {
+ 	    char *fok;
+@@ -372,7 +378,7 @@ static char * getTarSpec(const char *arg)
+ 		}
+ 		specfiles++;
+ 	    }
+-	    pclose(fp);
++	    rpclose(fp);
+ 	    gotspec = (specfiles == 1) && isSpecFile(specFile);
+ 	    if (specfiles > 1) {
+ 		rpmlog(RPMLOG_ERR, _("Found more than one spec file in %s\n"), arg);
+-- 
+2.56.0
+

diff --git a/0003-Add-a-variable-argument-list-to-rpopen.patch b/0003-Add-a-variable-argument-list-to-rpopen.patch
new file mode 100644
index 0000000..19a5b98
--- /dev/null
+++ b/0003-Add-a-variable-argument-list-to-rpopen.patch
@@ -0,0 +1,82 @@
+From b0ed834235f910a5b7ebe56daa6e0e034bb41349 Mon Sep 17 00:00:00 2001
+From: Michal Domonkos <mdomonko@redhat.com>
+Date: Thu, 22 Oct 2026 09:11:51 +0200
+Subject: [PATCH 3/3] Add a variable argument list to rpopen()
+
+Accept multiple positional arguments for the shell instead of just one.
+This will be needed in the next commits.
+
+No functional change.
+
+Backported from commit e7a086a8e203f123fbd37ead9b52188d1302ce0e.
+---
+ cliutils.c | 9 +++++++--
+ cliutils.h | 7 ++++---
+ rpmbuild.c | 2 +-
+ 3 files changed, 12 insertions(+), 6 deletions(-)
+
+diff --git a/cliutils.c b/cliutils.c
+index 2231ed1f1..6547e7bdb 100644
+--- a/cliutils.c
++++ b/cliutils.c
+@@ -87,10 +87,11 @@ int finishPipe(void)
+     return rc;
+ }
+ 
+-FILE* rpopen(const char *cmd, const char *arg)
++FILE* rpopen(const char *cmd, const char *arg, ...)
+ {
+     FILE *stream = NULL;
+     ARGV_t argv = NULL;
++    va_list ap;
+     int pipefd[2];
+     pid_t pid;
+ 
+@@ -101,7 +102,11 @@ FILE* rpopen(const char *cmd, const char *arg)
+     argvAdd(&argv, "-c");
+     argvAdd(&argv, cmd);
+     argvAdd(&argv, "sh");
+-    argvAdd(&argv, arg);
++
++    va_start(ap, arg);
++    for (const char *s = arg; s != NULL; s = va_arg(ap, const char *))
++	argvAdd(&argv, s);
++    va_end(ap);
+ 
+     if ((pid = fork()) == 0) {
+ 	dup2(pipefd[1], STDOUT_FILENO);
+diff --git a/cliutils.h b/cliutils.h
+index cda4bebdf..4aee1ae72 100644
+--- a/cliutils.h
++++ b/cliutils.h
+@@ -23,10 +23,11 @@ int initPipe(void);
+ int finishPipe(void);
+ 
+ /*
+- * A safe, read-only variant of popen(3) that passes untrusted input (arg) as a
+- * positional argument to sh(1) where the command (cmd) can read it via $1.
++ * A safe, read-only variant of popen(3) that passes untrusted input (args) as
++ * positional arguments to sh(1) where the command (cmd) can read them via $1,
++ * $2, and so on.
+  */
+-FILE *rpopen(const char *cmd, const char *arg);
++FILE *rpopen(const char *cmd, const char *arg, ...) RPM_GNUC_NULL_TERMINATED;
+ int rpclose(FILE *stream);
+ 
+ #endif /* _CLIUTIL_H */
+diff --git a/rpmbuild.c b/rpmbuild.c
+index ddc1e0750..63872325d 100644
+--- a/rpmbuild.c
++++ b/rpmbuild.c
+@@ -365,7 +365,7 @@ static char * getTarSpec(const char *arg)
+ 			"%{__tar} xOvof - --wildcards ", *spec,
+ 			" 2>&1 > ", specFile, NULL);
+ 
+-	if (!(fp = rpopen(cmd, arg))) {
++	if (!(fp = rpopen(cmd, arg, NULL))) {
+ 	    rpmlog(RPMLOG_ERR, _("Failed to open tar pipe: %m\n"));
+ 	} else {
+ 	    char *fok;
+-- 
+2.56.0
+

diff --git a/python3-rpm.spec b/python3-rpm.spec
index 7330b95..d5d690e 100644
--- a/python3-rpm.spec
+++ b/python3-rpm.spec
@@ -31,14 +31,14 @@
 
 %global rpmver 4.16.1.3
 #global snapver rc1
-%global rel 40
+%global rel 43
 %global sover 9
 %global rhelrel %{?snapver:0.%{snapver}.}%{rel}
 %global rel_next %{lua:print(tonumber(rpm.expand("%rel")) + 1)}
 %global rhelrel_next %{?snapver:0.%{snapver}.}%{rel_next}
 
 # Bump this for EPEL only rebuilds, reset when %%rel was bumped
-%global baserelease 2
+%global baserelease 1
 
 %global srcver %{rpmver}%{?snapver:-%{snapver}}
 %global srcdir %{?snapver:testing}%{!?snapver:rpm-%(echo %{rpmver} | cut -d'.' -f1-2).x}
@@ -128,6 +128,11 @@ Patch154: 0003-Add-support-for-spec-local-file-attributes-and-gener.patch
 Patch155: 0001-Allow-an-optional-override-clock-for-deterministic-t.patch
 Patch156: 0001-Improve-error-handling-on-keystore-load.patch
 Patch157: 0001-Sort-files-before-passing-to-file-attribute-dependen.patch
+Patch158: 0001-Prevent-command-injection-via-rpmbuild-t.patch
+Patch159: 0001-Extract-archiver-detection-out-of-doUncompress.patch
+Patch160: 0002-Prevent-command-injection-via-rpmbuild-t-filename.patch
+Patch161: 0003-Add-a-variable-argument-list-to-rpopen.patch
+Patch162: 0001-Fix-rpopen-rpclose-and-make-them-more-POSIXy.patch
 
 # These are not yet upstream
 Patch906: rpm-4.7.1-geode-i686.patch
@@ -427,6 +432,15 @@ make clean
 %{python3_sitearch}/rpm-%{rpmver}*.egg-info/
 
 %changelog
+* Mon Nov 09 2026 Michal Domonkos <mdomonko@redhat.com> - 4.16.1.3-43
+- Fix rpopen()/rpclose() and make them more POSIXy (RHEL-288157)
+
+* Mon Oct 26 2026 Michal Domonkos <mdomonko@redhat.com> - 4.16.1.3-42
+- CVE-2026-84837: Prevent command injection via rpmbuild -t filename (RHEL-288157)
+
+* Tue Oct 13 2026 Michal Domonkos <mdomonko@redhat.com> - 4.16.1.3-41
+- CVE-2026-78367: Prevent command injection via rpmbuild -t (RHEL-282745)
+
 * Tue Mar 17 2026 Miro Hrončok <mhroncok@redhat.com> - 4.16.1.3-40.2
 - Add python3.14-rpm
 

^ permalink raw reply related	[flat|nested] 2+ messages in thread
* [rpms/python3-rpm] epel9: Merge epel9-next into epel9
@ 2026-06-04 15:28 
  0 siblings, 0 replies; 2+ messages in thread
From:  @ 2026-06-04 15:28 UTC (permalink / raw)
  To: git-commits

A new commit has been pushed.

Repo   : rpms/python3-rpm
Branch : epel9
Commit : e64f2d8ccd93ec1d5f91826e7e4aca5a8e2a7401
Author : Miro Hrončok <miro@hroncok.cz>
Date   : 2026-06-04T17:04:00+02:00
Stats  : +254/-2 in 3 file(s)
URL    : https://src.fedoraproject.org/rpms/python3-rpm/c/e64f2d8ccd93ec1d5f91826e7e4aca5a8e2a7401?branch=epel9

Log:
Merge epel9-next into epel9

---
diff --git a/0001-Improve-error-handling-on-keystore-load.patch b/0001-Improve-error-handling-on-keystore-load.patch
new file mode 100644
index 0000000..8d16b69
--- /dev/null
+++ b/0001-Improve-error-handling-on-keystore-load.patch
@@ -0,0 +1,168 @@
+From 38ccf257f278e6b71f73dee9ccb568fe2ad3037a Mon Sep 17 00:00:00 2001
+From: Michal Domonkos <mdomonko@redhat.com>
+Date: Fri, 31 Oct 2025 11:21:28 +0100
+Subject: [PATCH 1/2] Obtain nvr string only once, before the loop
+
+Refactor loadKeyringFromDB() a bit so that the nvr string can be reused
+in multiple places. This will be handy in the next commit.
+
+No functional change.
+---
+ lib/rpmts.c | 7 +++----
+ 1 file changed, 3 insertions(+), 4 deletions(-)
+
+diff --git a/lib/rpmts.c b/lib/rpmts.c
+index 69888acfc..ceb021789 100644
+--- a/lib/rpmts.c
++++ b/lib/rpmts.c
+@@ -327,10 +327,12 @@ static int loadKeyringFromDB(rpmts ts)
+     while ((h = rpmdbNextIterator(mi)) != NULL) {
+ 	struct rpmtd_s pubkeys;
+ 	const char *key;
++	char *nvr;
+ 
+ 	if (!headerGet(h, RPMTAG_PUBKEYS, &pubkeys, HEADERGET_MINMEM))
+ 	   continue;
+ 
++	nvr = headerGetAsString(h, RPMTAG_NVR);
+ 	while ((key = rpmtdNextString(&pubkeys))) {
+ 	    uint8_t *pkt;
+ 	    size_t pktlen;
+@@ -341,9 +343,7 @@ static int loadKeyringFromDB(rpmts ts)
+ 		rpmPubkey *subkeys = rpmGetSubkeys(key, &subkeysCount);
+ 
+ 		if (rpmKeyringAddKey(ts->keyring, key) == 0) {
+-		    char *nvr = headerGetAsString(h, RPMTAG_NVR);
+ 		    rpmlog(RPMLOG_DEBUG, "added key %s to keyring\n", nvr);
+-		    free(nvr);
+ 		    nkeys++;
+ 		}
+ 		rpmPubkeyFree(key);
+@@ -352,12 +352,10 @@ static int loadKeyringFromDB(rpmts ts)
+ 		    rpmPubkey subkey = subkeys[i];
+ 
+ 		    if (rpmKeyringAddKey(ts->keyring, subkey) == 0) {
+-			char *nvr = headerGetAsString(h, RPMTAG_NVR);
+ 			rpmlog(RPMLOG_DEBUG,
+ 			    "added subkey %d of main key %s to keyring\n",
+ 			    i, nvr);
+ 
+-			free(nvr);
+ 			nkeys++;
+ 		    }
+ 		    rpmPubkeyFree(subkey);
+@@ -367,6 +365,7 @@ static int loadKeyringFromDB(rpmts ts)
+ 	    }
+ 	}
+ 	rpmtdFreeData(&pubkeys);
++	free(nvr);
+     }
+     rpmdbFreeIterator(mi);
+ 
+-- 
+2.51.1
+
+
+From c68a557146c594458fb00109863565651cbe8f0a Mon Sep 17 00:00:00 2001
+From: Michal Domonkos <mdomonko@redhat.com>
+Date: Fri, 31 Oct 2025 14:17:25 +0100
+Subject: [PATCH 2/2] Improve error handling on keystore load
+
+Report a failure to load a key, but only as a non-fatal warning so that
+other keys can still be loaded, if any. This behavior is in the spirit
+of #3996, too.
+
+Only emit *one* warning in the keystore_rpmdb, to keep the (code) noise
+down. This covers all three steps (rpmBase64Decode, rpmPubkeyNew and
+rpmKeyringAddKey). We don't need to check if key is NULL since that's
+handled by rpmKeyringAddKey() which returns immediately if that's the
+case.
+
+In the other two backends, we already handle a failure to *read* a key,
+so keep that and just add another warning for a failed addition.
+
+This would be difficult to test (especially in the rpmdb backend) so
+skimping on that here.
+
+(backported from commit 75de4f3eb28c686e7f73b750ca116a8e57b7a690)
+---
+ lib/rpmts.c | 18 +++++++++++++++---
+ 1 file changed, 15 insertions(+), 3 deletions(-)
+
+diff --git a/lib/rpmts.c b/lib/rpmts.c
+index ceb021789..f6fe38c7a 100644
+--- a/lib/rpmts.c
++++ b/lib/rpmts.c
+@@ -281,6 +281,7 @@ static int loadKeyringFromFiles(rpmts ts)
+     }
+ 
+     for (char **f = files; *f; f++) {
++	int rc = 1;
+ 	int subkeysCount, i;
+ 	rpmPubkey *subkeys;
+ 	rpmPubkey key = rpmPubkeyRead(*f);
+@@ -289,7 +290,7 @@ static int loadKeyringFromFiles(rpmts ts)
+ 	    rpmlog(RPMLOG_ERR, _("%s: reading of public key failed.\n"), *f);
+ 	    continue;
+ 	}
+-	if (rpmKeyringAddKey(ts->keyring, key) == 0) {
++	if ((rc = rpmKeyringAddKey(ts->keyring, key)) == 0) {
+ 	    nkeys++;
+ 	    rpmlog(RPMLOG_DEBUG, "added key %s to keyring\n", *f);
+ 	}
+@@ -305,10 +306,15 @@ static int loadKeyringFromFiles(rpmts ts)
+ 		    i, *f);
+ 
+ 		nkeys++;
++	    } else {
++		rc = 1;
+ 	    }
+ 	    rpmPubkeyFree(subkey);
+ 	}
+ 	free(subkeys);
++
++	if (rc)
++	    rpmlog(RPMLOG_WARNING, _("Could not load key %s\n"), *f);
+     }
+ exit:
+     free(pkpath);
+@@ -334,15 +340,16 @@ static int loadKeyringFromDB(rpmts ts)
+ 
+ 	nvr = headerGetAsString(h, RPMTAG_NVR);
+ 	while ((key = rpmtdNextString(&pubkeys))) {
++	    int rc = 1;
+ 	    uint8_t *pkt;
+ 	    size_t pktlen;
+ 
+-	    if (rpmBase64Decode(key, (void **) &pkt, &pktlen) == 0) {
++	    if ((rc = rpmBase64Decode(key, (void **) &pkt, &pktlen)) == 0) {
+ 		rpmPubkey key = rpmPubkeyNew(pkt, pktlen);
+ 		int subkeysCount, i;
+ 		rpmPubkey *subkeys = rpmGetSubkeys(key, &subkeysCount);
+ 
+-		if (rpmKeyringAddKey(ts->keyring, key) == 0) {
++		if ((rc = rpmKeyringAddKey(ts->keyring, key)) == 0) {
+ 		    rpmlog(RPMLOG_DEBUG, "added key %s to keyring\n", nvr);
+ 		    nkeys++;
+ 		}
+@@ -357,12 +364,17 @@ static int loadKeyringFromDB(rpmts ts)
+ 			    i, nvr);
+ 
+ 			nkeys++;
++		    } else {
++			rc = 1;
+ 		    }
+ 		    rpmPubkeyFree(subkey);
+ 		}
+ 		free(subkeys);
+ 		free(pkt);
+ 	    }
++
++	    if (rc)
++		rpmlog(RPMLOG_WARNING, _("Could not load key %s\n"), nvr);
+ 	}
+ 	rpmtdFreeData(&pubkeys);
+ 	free(nvr);
+-- 
+2.51.1
+

diff --git a/0001-Sort-files-before-passing-to-file-attribute-dependen.patch b/0001-Sort-files-before-passing-to-file-attribute-dependen.patch
new file mode 100644
index 0000000..0f4c312
--- /dev/null
+++ b/0001-Sort-files-before-passing-to-file-attribute-dependen.patch
@@ -0,0 +1,61 @@
+From 08d5e162c2ec3a415a5e657fd8b63f0cdf14ddd8 Mon Sep 17 00:00:00 2001
+From: Chris Riches <chris.riches@nutanix.com>
+Date: Thu, 5 Jun 2025 09:47:02 +0000
+Subject: [PATCH] Sort files before passing to file attribute dependency
+ generators
+
+The fc->fahash map is constructed in parallel, and so ends up with
+non-deterministic ordering of files. Passing this unordered list through
+to file attribute dependency generators can therefore result in
+non-reproducible RPM builds.
+
+In theory, a file attribute generator should only care about each
+individual file it is given, and so the order should not matter.
+However, some generators track state in-between files and so this
+property does not hold. Notably, the python3-rpm-generators in RHEL
+(ab)use this system to apply package-level dependencies that are based
+on the package name rather than the content of any particular file, and
+simply apply this to the first file that they see from a matching
+package. Therefore, different input file orderings will result in
+different files getting the dependency, and therefore different output
+RPMs.
+
+To avoid this, sort the files before passing them to the generators.
+Since the fc->fn array is already sorted by filename, we just need to
+sort the list of indices into that array.
+
+(backported from commit bc0b94026bc5651435819043394cbe9a766a4fd5)
+---
+ build/rpmfc.c | 9 +++++++++
+ 1 file changed, 9 insertions(+)
+
+diff --git a/build/rpmfc.c b/build/rpmfc.c
+index c3015ffcb..b5fb611db 100644
+--- a/build/rpmfc.c
++++ b/build/rpmfc.c
+@@ -1010,6 +1010,13 @@ static const struct applyDep_s applyDepTable[] = {
+     { 0, 0, NULL },
+ };
+ 
++static int compareInts(const void *a, const void *b)
++{
++    int ia = *((int*)a);
++    int ib = *((int*)b);
++    return ia > ib ? 1 : ia < ib ? -1 : 0;
++}
++
+ static int applyAttr(rpmfc fc, int aix, const char *aname,
+ 			const struct exclreg_s *excl,
+ 			const struct applyDep_s *dep)
+@@ -1032,6 +1039,8 @@ static int applyAttr(rpmfc fc, int aix, const char *aname,
+ 
+ 	if (!rstreq(cmd, "")) {
+ 	    char *ns = rpmfcAttrMacro(aname, "namespace", NULL);
++	    /* Sort for reproducibility - hashmap was constructed in parallel */
++	    qsort(ixs, n, sizeof(*ixs), compareInts);
+ 	    for (int i = 0; i < n; i++) {
+ 		if (rpmfcHelper(fc, ixs[i], excl, dep->type, dep->tag,
+ 				ns, cmd, callable))
+-- 
+2.51.1
+

diff --git a/python3-rpm.spec b/python3-rpm.spec
index 21f0240..7330b95 100644
--- a/python3-rpm.spec
+++ b/python3-rpm.spec
@@ -31,14 +31,14 @@
 
 %global rpmver 4.16.1.3
 #global snapver rc1
-%global rel 39
+%global rel 40
 %global sover 9
 %global rhelrel %{?snapver:0.%{snapver}.}%{rel}
 %global rel_next %{lua:print(tonumber(rpm.expand("%rel")) + 1)}
 %global rhelrel_next %{?snapver:0.%{snapver}.}%{rel_next}
 
 # Bump this for EPEL only rebuilds, reset when %%rel was bumped
-%global baserelease 1
+%global baserelease 2
 
 %global srcver %{rpmver}%{?snapver:-%{snapver}}
 %global srcdir %{?snapver:testing}%{!?snapver:rpm-%(echo %{rpmver} | cut -d'.' -f1-2).x}
@@ -126,6 +126,8 @@ Patch152: 0001-Fix-a-race-condition-in-brp-strip.patch
 Patch153: 0002-Store-configurable-digest-s-on-packages-from-verific.patch
 Patch154: 0003-Add-support-for-spec-local-file-attributes-and-gener.patch
 Patch155: 0001-Allow-an-optional-override-clock-for-deterministic-t.patch
+Patch156: 0001-Improve-error-handling-on-keystore-load.patch
+Patch157: 0001-Sort-files-before-passing-to-file-attribute-dependen.patch
 
 # These are not yet upstream
 Patch906: rpm-4.7.1-geode-i686.patch
@@ -241,6 +243,8 @@ programs that will manipulate RPM packages and databases.}
 %python3x_package
 %global python3_pkgversion 3.13
 %python3x_package
+%global python3_pkgversion 3.14
+%python3x_package
 
 %prep
 %autosetup -n rpm-%{srcver} %{?with_int_bdb:-a 1} -p1
@@ -305,6 +309,8 @@ pushd python
 %py3_build
 %global python3_pkgversion 3.13
 %py3_build
+%global python3_pkgversion 3.14
+%py3_build
 popd
 
 %install
@@ -319,6 +325,8 @@ pushd python
 %py3_install
 %global python3_pkgversion 3.13
 %py3_install
+%global python3_pkgversion 3.14
+%py3_install
 popd
 
 cat > $RPM_BUILD_ROOT/%{rpmhome}/debugedit << END
@@ -386,6 +394,8 @@ rm -r %{buildroot}%{_sysconfdir}
 %py3_check_import rpm rpm.transaction
 %global python3_pkgversion 3.13
 %py3_check_import rpm rpm.transaction
+%global python3_pkgversion 3.14
+%py3_check_import rpm rpm.transaction
 %if %{with check}
 make check TESTSUITEFLAGS=-j%{_smp_build_ncpus} || (cat tests/rpmtests.log; exit 1)
 # rpm >= 4.16.0 testsuite leaves a read-only tree behind, clean it up
@@ -410,7 +420,20 @@ make clean
 %{python3_sitearch}/rpm/
 %{python3_sitearch}/rpm-%{rpmver}*.egg-info/
 
+%global python3_pkgversion 3.14
+%files -n python%{python3_pkgversion}-rpm
+%license COPYING
+%{python3_sitearch}/rpm/
+%{python3_sitearch}/rpm-%{rpmver}*.egg-info/
+
 %changelog
+* Tue Mar 17 2026 Miro Hrončok <mhroncok@redhat.com> - 4.16.1.3-40.2
+- Add python3.14-rpm
+
+* Fri Nov 21 2025 Michal Domonkos <mdomonko@redhat.com> - 4.16.1.3-40
+- Improve error handling on keystore load (RHEL-114837)
+- Sort files before passing to file attr dependency generators (RHEL-95376)
+
 * Wed Aug 20 2025 Michal Domonkos <mdomonko@redhat.com> - 4.16.1.3-39
 - Allow an optional "override clock" for deterministic timestamps (RHEL-106672)
 

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-11-13 18:33 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-13 18:33 [rpms/python3-rpm] epel9: Merge epel9-next into epel9 
  -- strict thread matches above, loose matches on Subject: below --
2026-06-04 15:28 

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox