Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package rpm for openSUSE:Factory checked in at 2026-11-21 21:44:34 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/rpm (Old) and /work/SRC/openSUSE:Factory/.rpm.new.1340718 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "rpm" Sat Nov 21 21:44:34 2026 rev:331 rq:1397286 version:4.20.1 Changes: -------- +++ only whitespace diff in changes, re-diffing rpm-plugin-imaevmsign.changes: same change --- /work/SRC/openSUSE:Factory/rpm/rpm.changes 2026-09-18 22:04:06.268472761 +0200 +++ /work/SRC/openSUSE:Factory/.rpm.new.1340718/rpm.changes 2026-11-21 21:44:37.064610019 +0100 @@ -1,0 +2,26 @@ +Thu Nov 12 10:26:45 CET 2026 - Michael Schroeder <[email protected]> + +- fix fapolicyd plugin EAGAIN busy loop + * new patch: fapolicyd_busyloop.diff +- fix command injection in rpmbuild -t [bsc#1278428] [bsc#1278005] + [CVE-2026-84837] [CVE-2026-78367] + * new patch: rpmbuild_inj.diff +- fix command injection in rpmuncompress [bsc#1278004] [bsc#1278426] + [CVE-2026-84233] [CVE-2026-84838] + * new patch: rpmuncompress_inj.diff +- drop macro expansion from manifest parser [bsc#1282796] + [CVE-2026-95519] + * new patch: manifest_noexpand.diff +- verify symlink size in cpio files [bsc#1283361] [CVE-2026-95520] + * new patch: cpio_symlinksize.diff +- fix hex2binv memory overwrite with i18n string types + [bsc#1283733] [CVE-2026-103242] + * new patch: hex2binv.diff +- fix rpmRelocateSrpmFileList expanding the basename of a file + [bsc#1282795] [CVE-2026-95521] + * new patch: relocationexpand.diff +- fix rpmbuild not returning an error for missing sources/patches + [bsc#1275197] + * new patch: nopatcherror.diff + +------------------------------------------------------------------- @@ -4 +30 @@ -- Don’t be dependent on python3-base, it is perfectly OK to use +- Don't be dependent on python3-base, it is perfectly OK to use New: ---- cpio_symlinksize.diff fapolicyd_busyloop.diff hex2binv.diff manifest_noexpand.diff nopatcherror.diff relocationexpand.diff rpmbuild_inj.diff rpmuncompress_inj.diff ----------(New B)---------- New:/work/SRC/openSUSE:Factory/.rpm.new.1340718/rpm.changes-- verify symlink size in cpio files [bsc#1283361] [CVE-2026-95520] /work/SRC/openSUSE:Factory/.rpm.new.1340718/rpm.changes: * new patch: cpio_symlinksize.diff /work/SRC/openSUSE:Factory/.rpm.new.1340718/rpm.changes-- fix hex2binv memory overwrite with i18n string types New:/work/SRC/openSUSE:Factory/.rpm.new.1340718/rpm.changes-- fix fapolicyd plugin EAGAIN busy loop /work/SRC/openSUSE:Factory/.rpm.new.1340718/rpm.changes: * new patch: fapolicyd_busyloop.diff /work/SRC/openSUSE:Factory/.rpm.new.1340718/rpm.changes-- fix command injection in rpmbuild -t [bsc#1278428] [bsc#1278005] New:/work/SRC/openSUSE:Factory/.rpm.new.1340718/rpm.changes- [bsc#1283733] [CVE-2026-103242] /work/SRC/openSUSE:Factory/.rpm.new.1340718/rpm.changes: * new patch: hex2binv.diff /work/SRC/openSUSE:Factory/.rpm.new.1340718/rpm.changes-- fix rpmRelocateSrpmFileList expanding the basename of a file New:/work/SRC/openSUSE:Factory/.rpm.new.1340718/rpm.changes- [CVE-2026-95519] /work/SRC/openSUSE:Factory/.rpm.new.1340718/rpm.changes: * new patch: manifest_noexpand.diff /work/SRC/openSUSE:Factory/.rpm.new.1340718/rpm.changes-- verify symlink size in cpio files [bsc#1283361] [CVE-2026-95520] New:/work/SRC/openSUSE:Factory/.rpm.new.1340718/rpm.changes- [bsc#1275197] /work/SRC/openSUSE:Factory/.rpm.new.1340718/rpm.changes: * new patch: nopatcherror.diff /work/SRC/openSUSE:Factory/.rpm.new.1340718/rpm.changes- New:/work/SRC/openSUSE:Factory/.rpm.new.1340718/rpm.changes- [bsc#1282795] [CVE-2026-95521] /work/SRC/openSUSE:Factory/.rpm.new.1340718/rpm.changes: * new patch: relocationexpand.diff /work/SRC/openSUSE:Factory/.rpm.new.1340718/rpm.changes-- fix rpmbuild not returning an error for missing sources/patches New:/work/SRC/openSUSE:Factory/.rpm.new.1340718/rpm.changes- [CVE-2026-84837] [CVE-2026-78367] /work/SRC/openSUSE:Factory/.rpm.new.1340718/rpm.changes: * new patch: rpmbuild_inj.diff /work/SRC/openSUSE:Factory/.rpm.new.1340718/rpm.changes-- fix command injection in rpmuncompress [bsc#1278004] [bsc#1278426] New:/work/SRC/openSUSE:Factory/.rpm.new.1340718/rpm.changes- [CVE-2026-84233] [CVE-2026-84838] /work/SRC/openSUSE:Factory/.rpm.new.1340718/rpm.changes: * new patch: rpmuncompress_inj.diff /work/SRC/openSUSE:Factory/.rpm.new.1340718/rpm.changes-- drop macro expansion from manifest parser [bsc#1282796] ----------(New E)---------- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ python-rpm.spec ++++++ --- /var/tmp/diff_new_pack.lfTazw/_old 2026-11-21 21:44:38.947688841 +0100 +++ /var/tmp/diff_new_pack.lfTazw/_new 2026-11-21 21:44:38.949688925 +0100 @@ -1,6 +1,7 @@ # # spec file for package python-rpm # +# Copyright (c) 2026 SUSE LLC # Copyright (c) 2026 SUSE LLC and contributors # Copyright (c) 2017 Neal Gompa <[email protected]>. # ++++++ rpm-plugin-imaevmsign.spec ++++++ --- /var/tmp/diff_new_pack.lfTazw/_old 2026-11-21 21:44:38.988690558 +0100 +++ /var/tmp/diff_new_pack.lfTazw/_new 2026-11-21 21:44:38.990690641 +0100 @@ -1,6 +1,7 @@ # # spec file for package rpm-plugin-imaevmsign # +# Copyright (c) 2026 SUSE LLC # Copyright (c) 2026 SUSE LLC and contributors # # All modifications and additions to the file contributed by third parties ++++++ rpm.spec ++++++ --- /var/tmp/diff_new_pack.lfTazw/_old 2026-11-21 21:44:39.018691813 +0100 +++ /var/tmp/diff_new_pack.lfTazw/_new 2026-11-21 21:44:39.020691897 +0100 @@ -1,6 +1,7 @@ # # spec file for package rpm # +# Copyright (c) 2026 SUSE LLC # Copyright (c) 2026 SUSE LLC and contributors # # All modifications and additions to the file contributed by third parties @@ -133,6 +134,14 @@ Patch162: imaevmsignplugin.diff Patch163: rpmuncompress.diff Patch164: ndbharden.diff +Patch165: fapolicyd_busyloop.diff +Patch166: rpmbuild_inj.diff +Patch167: rpmuncompress_inj.diff +Patch168: manifest_noexpand.diff +Patch169: cpio_symlinksize.diff +Patch170: hex2binv.diff +Patch171: relocationexpand.diff +Patch172: nopatcherror.diff Patch6464: auto-config-update-aarch64-ppc64le.diff Requires: (rpm-plugin-selinux if selinux-policy) BuildRoot: %{_tmppath}/%{name}-%{version}-build @@ -291,7 +300,8 @@ %patch -P 139 %patch -P 141 -P 142 %patch -P 150 -P 151 -P 154 -P 155 -P 156 -P 157 -P 158 -P 159 -%patch -P 160 -P 161 -P 162 -P 163 -P 164 +%patch -P 160 -P 161 -P 162 -P 163 -P 164 -P 165 -P 166 -P 167 +%patch -P 168 -P 169 -P 170 -P 171 -P 172 %ifarch aarch64 ppc64le riscv64 loongarch64 %patch -P 6464 ++++++ cpio_symlinksize.diff ++++++ --- lib/rpmfi.c.orig 2026-11-12 10:26:25.016820301 +0000 +++ lib/rpmfi.c 2026-11-12 10:27:46.568714703 +0000 @@ -2259,8 +2259,12 @@ static int iterReadArchiveNext(rpmfi fi) if (!(numlinks > 1 && links[numlinks-1] != fx)) fsize = rpmfilesFSize(fi->files, fx); } else if (S_ISLNK(mode)) { - /* Skip over symlink target data in payload */ + /* Cross-check symlink data, strings are capped by header size. */ rpm_loff_t lsize = rpmfilesFSize(fi->files, fx); + const char *link = rpmfilesFLink(fi->files, fx); + if (link == NULL || lsize != strlen(link)) + return RPMERR_BAD_HEADER; + /* Skip over symlink target data in payload */ char *buf = (char *)xmalloc(lsize + 1); if (rpmcpioRead(fi->archive, buf, lsize) != lsize) rc = RPMERR_READ_FAILED; ++++++ fapolicyd_busyloop.diff ++++++ --- plugins/fapolicyd.c.orig 2025-02-19 15:29:33.000000000 +0000 +++ plugins/fapolicyd.c 2026-11-11 13:01:41.071724076 +0000 @@ -11,15 +11,19 @@ #include <inttypes.h> #include <sys/stat.h> +#define MAX_WRITE_ERROR_LOGS 5 + struct fapolicyd_data { int fd; long changed_files; + unsigned int write_error_logs; const char * fifo_path; }; static struct fapolicyd_data fapolicyd_state = { .fd = -1, .changed_files = 0, + .write_error_logs = 0, .fifo_path = "/run/fapolicyd/fapolicyd.fifo", }; @@ -84,9 +88,15 @@ static rpmRC write_fifo(struct fapolicyd while (written < len) { if ((n = write(state->fd, str + written, len - written)) < 0) { - if (errno == EINTR || errno == EAGAIN) + if (errno == EINTR) continue; - rpmlog(RPMLOG_DEBUG, "Write: %s -> %s\n", state->fifo_path, strerror(errno)); + + /* Let the outer loop back off and reopen on EAGAIN. */ + if (state->write_error_logs < MAX_WRITE_ERROR_LOGS) { + rpmlog(RPMLOG_DEBUG, "Write: %s -> %s\n", + state->fifo_path, strerror(errno)); + state->write_error_logs++; + } goto bad; } written += n; @@ -148,6 +158,9 @@ static void try_to_write_to_fifo(struct static rpmRC fapolicyd_init(rpmPlugin plugin, rpmts ts) { + /* Limit repeated write errors independently for each transaction. */ + fapolicyd_state.write_error_logs = 0; + if (rpmtsFlags(ts) & (RPMTRANS_FLAG_TEST|RPMTRANS_FLAG_BUILD_PROBS)) goto end; ++++++ hex2binv.diff ++++++ --- lib/header.c.orig 2026-11-12 12:26:27.098914664 +0000 +++ lib/header.c 2026-11-12 12:26:29.986910586 +0000 @@ -1374,6 +1374,9 @@ exit: td->flags |= RPMTD_ALLOCED; } + if (td->data) + td->size = strlen((const char *)td->data) + 1; + return 1; } --- lib/misc.h.orig 2025-02-19 15:29:33.000000000 +0000 +++ lib/misc.h 2026-11-12 12:26:29.986910586 +0000 @@ -58,4 +58,7 @@ RPM_GNUC_INTERNAL void rpmRelocationBuild(Header h, rpmRelocation *rawrelocs, int *rnrelocs, rpmRelocation **rrelocs, uint8_t **rbadrelocs); +RPM_GNUC_INTERNAL +int rpmIsValidHex(const char *str, size_t slen); + #endif /* H_MISC */ --- lib/rpmfi.c.orig 2026-11-12 12:26:27.146914596 +0000 +++ lib/rpmfi.c 2026-11-12 12:26:29.986910586 +0000 @@ -20,6 +20,7 @@ #include "rpmte_internal.h" /* relocations */ #include "cpio.h" /* XXX CPIO_FOO */ #include "fsm.h" /* rpmpsm stuff for now */ +#include "misc.h" #include "rpmug.h" #include "rpmio_internal.h" /* fdInit/FiniDigest */ @@ -1480,16 +1481,23 @@ err: * accessed via offsets to a contiguous binary blob. Empty values * are represented by identical consequtive offsets. The offsets array * always has one extra element to allow calculating the size of the - * last element. + * last element. Return zero on success. */ -static uint8_t *hex2binv(Header h, rpmTagVal tag, rpm_count_t num, - uint32_t **offsetp) +static int hex2binv(Header h, rpmTagVal tag, rpm_count_t num, + uint32_t **offsetp, unsigned char **binp) { struct rpmtd_s td; uint8_t *bin = NULL; uint32_t *offs = NULL; + int rc = 1; /* assume failure */ - if (headerGet(h, tag, &td, HEADERGET_MINMEM) && rpmtdCount(&td) == num) { + /* File signature presence is not required */ + if (!headerGet(h, tag, &td, HEADERGET_MINMEM)) { + rc = 0; + goto exit; + } + + if (rpmtdSize(&td) && rpmtdCount(&td) == num) { const char *s; int i = 0; uint8_t *t = bin = (uint8_t *)xmalloc(((rpmtdSize(&td) / 2) + 1)); @@ -1498,7 +1506,7 @@ static uint8_t *hex2binv(Header h, rpmTa while ((s = rpmtdNextString(&td))) { uint32_t slen = strlen(s); uint32_t len = slen / 2; - if (slen % 2) { + if (!rpmIsValidHex(s, slen)) { bin = _free(bin); offs = _free(offs); goto exit; @@ -1510,11 +1518,13 @@ static uint8_t *hex2binv(Header h, rpmTa } offs[i] = t - bin; *offsetp = offs; + rc = 0; } exit: + *binp = bin; rpmtdFreeData(&td); - return bin; + return rc; } /* Convert a tag of hex strings to binary presentation */ @@ -1671,8 +1681,9 @@ static int rpmfilesPopulate(rpmfiles fi, fi->signatures = NULL; /* grab hex signatures from header and store in binary format */ if (!(flags & RPMFI_NOFILESIGNATURES)) { - fi->signatures = hex2binv(h, RPMTAG_FILESIGNATURES, - totalfc, &fi->signatureoffs); + if (hex2binv(h, RPMTAG_FILESIGNATURES, totalfc, &fi->signatureoffs, &fi->signatures)) { + goto err; + } } fi->veritysigs = NULL; --- lib/rpmtd.c.orig 2025-02-19 15:29:33.000000000 +0000 +++ lib/rpmtd.c 2026-11-12 12:26:29.986910586 +0000 @@ -443,15 +443,25 @@ rpmsid * rpmtdToPool(rpmtd td, rpmstrPoo { rpmsid *sids = NULL; - if (pool && td) { + if (pool && rpmtdClass(td) == RPM_STRING_CLASS) { const char **strings = (const char **)td->data; + sids = (rpmsid *)xmalloc(td->count * sizeof(*sids)); switch (td->type) { + case RPM_STRING_TYPE: + /* Single strings are stored differently */ + if (td->count == 1) { + sids[0] = rpmstrPoolId(pool, (const char *)td->data, 1); + break; + } + /* Otherwise fallthrough to the array case */ case RPM_STRING_ARRAY_TYPE: case RPM_I18NSTRING_TYPE: - sids = (rpmsid *)xmalloc(td->count * sizeof(*sids)); for (rpm_count_t i = 0; i < td->count; i++) sids[i] = rpmstrPoolId(pool, strings[i], 1); break; + default: + sids = _free(sids); /* can't happen */ + break; } } return sids; --- lib/rpmvs.c.orig 2025-02-19 15:29:33.000000000 +0000 +++ lib/rpmvs.c 2026-11-12 12:27:20.494839255 +0000 @@ -6,6 +6,7 @@ #include <rpm/rpmlog.h> #include "rpmvs.h" #include "rpmpgpval.h" +#include "misc.h" #include "debug.h" @@ -113,13 +114,13 @@ static int sinfoLookup(rpmTagVal tag) return ix; } -static int validHex(const char *str, size_t slen) +int rpmIsValidHex(const char *str, size_t slen) { int valid = 0; /* Assume invalid */ const char *b; - /* Our hex data is always even sized and at least sha-1 long */ - if (slen % 2 || slen < 40) + /* Our hex data is always even sized */ + if (slen % 2) goto exit; for (b = str ; *b != '\0'; b++) { @@ -220,7 +221,8 @@ static void rpmsinfoInit(const struct vf if (td->type == RPM_BIN_TYPE) { sinfo->dig = rpmhex((const uint8_t *)data, dlen); } else { - if (!validHex((const char *)data, dlen)) { + /* Our hex data is always at least sha-1 long */ + if (dlen < 40 || !rpmIsValidHex((const char *)data, dlen)) { rasprintf(&sinfo->msg, _("%s: tag %u: invalid hex"), origin, td->tag); goto exit; ++++++ manifest_noexpand.diff ++++++ --- lib/rpmgi.c.orig 2026-11-12 10:17:02.593553189 +0000 +++ lib/rpmgi.c 2026-11-12 10:17:56.705482598 +0000 @@ -49,15 +49,13 @@ struct rpmgi_s { */ static FD_t rpmgiOpen(const char * path, const char * fmode) { - char * fn = rpmExpand(path, NULL); - FD_t fd = Fopen(fn, fmode); + FD_t fd = Fopen(path, fmode); if (fd == NULL || Ferror(fd)) { - rpmlog(RPMLOG_ERR, _("open of %s failed: %s\n"), fn, Fstrerror(fd)); + rpmlog(RPMLOG_ERR, _("open of %s failed: %s\n"), path, Fstrerror(fd)); if (fd != NULL) (void) Fclose(fd); fd = NULL; } - free(fn); return fd; } ++++++ nopatcherror.diff ++++++ --- build/parsePrep.c.orig 2026-11-12 13:07:39.327881767 +0000 +++ build/parsePrep.c 2026-11-12 13:09:55.007732419 +0000 @@ -42,6 +42,7 @@ static int notCompressed(const char * fn /** * Expand %patchN macro into %prep scriptlet. * @param spec build info + * @param mb macro buffer * @param c patch index * @param strip patch level (i.e. patch -p argument) * @param db saved file suffix (i.e. patch --suffix argument) @@ -54,7 +55,8 @@ static int notCompressed(const char * fn * @return expanded %patch macro (NULL on error) */ -static char *doPatch(rpmSpec spec, uint32_t c, int strip, const char *db, +static char *doPatch(rpmSpec spec, rpmMacroBuf mb, + uint32_t c, int strip, const char *db, int reverse, int removeEmpties, int fuzz, const char *dir, const char *outfile, int setUtc) { @@ -69,7 +71,7 @@ static char *doPatch(rpmSpec spec, uint3 char *patchcmd; if ((sp = findSource(spec, c, RPMBUILD_ISPATCH)) == NULL) { - rpmlog(RPMLOG_ERR, _("No patch number %u\n"), c); + rpmMacroBufErr(mb, 1, _("No patch number %u\n"), c); goto exit; } @@ -121,17 +123,19 @@ exit: /** * Expand %setup macro into %prep scriptlet. * @param spec build info + * @param mb macro buffer * @param c source index * @param quietly should -vv be omitted from tar? * @return expanded %setup macro (NULL on error) */ -static char *doUntar(rpmSpec spec, uint32_t c, int quietly, int autoPath) +static char *doUntar(rpmSpec spec, rpmMacroBuf mb, + uint32_t c, int quietly, int autoPath) { char *buf = NULL; struct Source *sp; if ((sp = findSource(spec, c, RPMBUILD_ISSOURCE)) == NULL) { - rpmlog(RPMLOG_ERR, _("No source number %u\n"), c); + rpmMacroBufErr(mb, 1, _("No source number %u\n"), c); goto exit; } @@ -202,7 +206,7 @@ void doSetupMacro(rpmMacroBuf mb, rpmMac goto exit; } - { char *chptr = doUntar(spec, num, quietly, 0); + { char *chptr = doUntar(spec, mb, num, quietly, 0); if (chptr == NULL) goto exit; @@ -259,7 +263,7 @@ void doSetupMacro(rpmMacroBuf mb, rpmMac /* do the default action */ if (!skipDefaultAction) { - char *chptr = doUntar(spec, 0, quietly, autoPath); + char *chptr = doUntar(spec, mb, 0, quietly, autoPath); if (!chptr) goto exit; appendMb(mb, chptr, 1); @@ -379,7 +383,7 @@ void doPatchMacro(rpmMacroBuf mb, rpmMac *patch, line); goto exit; } - s = doPatch(spec, pnum, opt_p, opt_b, opt_R, opt_E, opt_F, opt_d, opt_o, opt_Z); + s = doPatch(spec, mb, pnum, opt_p, opt_b, opt_R, opt_E, opt_F, opt_d, opt_o, opt_Z); if (s == NULL) { goto exit; } ++++++ relocationexpand.diff ++++++ --- lib/relocation.c.orig 2026-11-12 11:55:12.665584830 +0000 +++ lib/relocation.c 2026-11-12 12:07:11.356560644 +0000 @@ -450,10 +450,12 @@ int rpmRelocateSrpmFileList(Header h, co headerGet(h, RPMTAG_ORIGBASENAMES, &filenames, HEADERGET_ALLOC); for (int i = 0; (bn = rpmtdNextString(&filenames)); i++) { int spec = (i == specix); - char *fn = rpmGenPath(rootDir, - spec ? "%{_specdir}" : "%{_sourcedir}", bn); + char *fndir = rpmGenPath(rootDir, + spec ? "%{_specdir}" : "%{_sourcedir}", NULL); + char *fn = rstrscat(NULL, fndir, "/", bn, NULL); headerPutString(h, RPMTAG_OLDFILENAMES, fn); free(fn); + free(fndir); } rpmtdFreeData(&filenames); headerConvert(h, HEADERCONV_COMPRESSFILELIST); ++++++ rpmbuild_inj.diff ++++++ --- build/parseSpec.c.orig 2026-11-12 10:11:27.377993573 +0000 +++ build/parseSpec.c 2026-11-12 10:11:31.041988755 +0000 @@ -1310,7 +1310,7 @@ static rpmSpec parseSpec(const char *spe /* Set up a new Spec structure with no packages. */ spec = newSpec(); - spec->specFile = rpmGetPath(specFile, NULL); + spec->specFile = rpmCleanPath(xstrdup(specFile)); addMacro(spec->macros, "_specfile", NULL, spec->specFile, RMIL_SPEC); pushOFI(spec, spec->specFile); /* If explicit --buildroot was passed, grab hold of it */ --- tools/cliutils.c.orig 2025-02-19 15:29:33.000000000 +0000 +++ tools/cliutils.c 2026-11-12 10:11:31.041988755 +0000 @@ -11,6 +11,7 @@ #include "debug.h" static pid_t pipeChild = 0; +static pid_t rpopenChild = 0; RPM_GNUC_NORETURN void argerror(const char * desc) @@ -83,3 +84,64 @@ int finishPipe(void) } return rc; } + +FILE* rpopen(const char *cmd, const char *arg, ...) +{ + FILE *fp = NULL; + int pipefd[2]; + ARGV_t argv = NULL; + va_list ap; + + if (pipe(pipefd) < 0) + 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, "--"); + 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 ((rpopenChild = fork()) == 0) { + dup2(pipefd[1], STDOUT_FILENO); + close(pipefd[1]); + close(pipefd[0]); + execv(argv[0], argv); + _exit(127); + } else if (rpopenChild == -1) { + fclose(fp); + fp = NULL; + } + + close(pipefd[1]); + argvFree(argv); + + return fp; +} + +int rpclose(FILE *fp) +{ + int status = -1; + pid_t reaped; + + fclose(fp); + do { + reaped = waitpid(rpopenChild, &status, 0); + } while (reaped == -1 && errno == EINTR); + + if (reaped == -1) + return -1; + + return status; +} --- tools/cliutils.h.orig 2025-02-19 15:29:33.000000000 +0000 +++ tools/cliutils.h 2026-11-12 10:11:31.041988755 +0000 @@ -26,6 +26,15 @@ int initPipe(void); int finishPipe(void); +/* + * 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, ...) RPM_GNUC_NULL_TERMINATED; + +int rpclose(FILE *fp); + #ifdef __cplusplus } #endif --- tools/rpmbuild.c.orig 2025-02-19 15:29:33.000000000 +0000 +++ tools/rpmbuild.c 2026-11-12 10:12:30.257910884 +0000 @@ -360,6 +360,8 @@ static char * getTarSpec(const char *arg { char *specFile = NULL; char *specFinal = NULL; + char *specDir = NULL; + char *specBase = NULL; const char **spec; char tarbuf[BUFSIZ]; int gotspec = 0; @@ -375,11 +377,11 @@ static char * getTarSpec(const char *arg char *cmd; int specfiles = 0; - cmd = rpmExpand("%{uncompress: ", arg, "} | ", + cmd = rpmExpand("%{uncompress: \"$1\" } | ", "%{__tar} xOvof - --wildcards ", *spec, " 2>&1 > ", specFile, NULL); - if (!(fp = popen(cmd, "r"))) { + if (!(fp = rpopen(cmd, arg, NULL))) { rpmlog(RPMLOG_ERR, _("Failed to open tar pipe: %m\n")); } else { char *fok; @@ -392,7 +394,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); @@ -408,9 +410,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); @@ -421,6 +425,7 @@ static char * getTarSpec(const char *arg exit: free(specFile); + free(specDir); Fclose(fd); return specFinal; } ++++++ rpmuncompress_inj.diff ++++++ --- tools/CMakeLists.txt.orig 2026-11-12 10:00:15.794894475 +0000 +++ tools/CMakeLists.txt 2026-11-12 10:00:24.010883351 +0000 @@ -11,7 +11,7 @@ add_executable(rpmqpack rpmqpack.c) add_executable(rpmdeps rpmdeps.c) add_executable(rpmgraph rpmgraph.c) add_executable(rpmlua rpmlua.c) -add_executable(rpmuncompress rpmuncompress.c) +add_executable(rpmuncompress rpmuncompress.c cliutils) add_executable(rpmdump rpmdump.c) target_link_libraries(rpmsign PRIVATE librpmsign) --- tools/rpmuncompress.c.orig 2026-11-12 10:00:15.806894459 +0000 +++ tools/rpmuncompress.c 2026-11-12 10:07:55.854271694 +0000 @@ -12,6 +12,7 @@ #include <rpm/rpmcli.h> #include <rpm/rpmstring.h> +#include "cliutils.h" #include "debug.h" static int verbose = 0; @@ -34,7 +35,7 @@ static struct poptOption optionsTable[] POPT_TABLEEND }; -struct archiveType_s { +typedef const struct archiveType_s { int compressed; int extractable; const char *cmd; @@ -42,7 +43,9 @@ struct archiveType_s { const char *quiet; const char *dest; int setTZ; -} archiveTypes[] = { +} archiveType; + +static archiveType const archiveTypes[] = { { COMPRESSED_NOT, 0, "%{__cat}" , "", "", "", 0 }, { COMPRESSED_OTHER, 0, "%{__gzip}", "-dc", "", "", 0 }, { COMPRESSED_BZIP2, 0, "%{__bzip2}", "-dc", "", "", 0 }, @@ -57,13 +60,13 @@ struct archiveType_s { { -1, 0, NULL, NULL, NULL, 0 }, }; -static const struct archiveType_s *getArchiver(const char *fn) +static archiveType *getArchiver(const char *fn) { - const struct archiveType_s *archiver = NULL; + archiveType *archiver = NULL; rpmCompressedMagic compressed = COMPRESSED_NOT; if (rpmFileIsCompressed(fn, &compressed) == 0) { - for (const struct archiveType_s *at = archiveTypes; at->cmd; at++) { + for (archiveType *at = archiveTypes; at->cmd; at++) { if (compressed == at->compressed) { archiver = at; break; @@ -74,15 +77,14 @@ static const struct archiveType_s *getAr return archiver; } -static char *doUncompress(const char *fn) +static char *doUncompress(archiveType *at, const char *arg) { char *cmd = NULL; - const struct archiveType_s *at = getArchiver(fn); if (at) { cmd = rpmExpand(at->setTZ ? "TZ=UTC " : "", at->cmd, " ", at->unpack, NULL); /* path must not be expanded */ - cmd = rstrscat(&cmd, " ", fn, NULL); + cmd = rstrscat(&cmd, " ", arg, NULL); } return cmd; } @@ -91,11 +93,11 @@ static char *doUncompress(const char *fn * Detect if an archive has a single top level entry, and it's a directory. * * @param path path of the archive - * @return only top level directory (if any), - * NULL if it contains multiple top level entries or a single file - * or on archive error + * @return 1 if the archive has a single top level, directory entry, + * 0 otherwise, + * -1 on archive error */ -static char * singleRoot(const char *path) +static int singleRoot(const char *path) { struct archive *a; struct archive_entry *entry; @@ -139,37 +141,31 @@ static char * singleRoot(const char *pat } } - rootName[rootLen - 1] = '\0'; ret = 1; afree: + free(rootName); r = archive_read_free(a); if (r != ARCHIVE_OK) ret = -1; - if (ret != 1) - rootName = _free(rootName); - - return rootName; + return ret; } -static char *doUntar(const char *fn) +static char *doUntar(archiveType *at, int sr, const char *bn, const char *fn) { - const struct archiveType_s *at = NULL; char *buf = NULL; char *tar = NULL; const char *taropts = verbose ? "-xvvof" : "-xof"; char *mkdir = NULL; char *stripcd = NULL; - if ((at = getArchiver(fn)) == NULL) + if (at == NULL) goto exit; int needtar = (at->extractable == 0); if (dstpath) { - char * sr = singleRoot(fn); - /* if the archive has multiple entries, just extract it into the * specified destination path, otherwise also strip the first path * entry @@ -196,7 +192,6 @@ static char *doUntar(const char *fn) rasprintf(&stripcd, "%s'%s'", at->dest, dstpath); } } - free(sr); } else { mkdir = xstrdup(""); stripcd = xstrdup(""); @@ -209,30 +204,20 @@ static char *doUntar(const char *fn) at->cmd, " ", at->unpack, " ", verbose ? "" : at->quiet, NULL); if (needtar) { - rasprintf(&buf, "%s %s '%s' | %s %s - %s", mkdir, zipper, fn, tar, taropts, stripcd); + rasprintf(&buf, "%s %s %s | %s %s - %s", mkdir, zipper, fn, tar, taropts, stripcd); } else if (at->compressed == COMPRESSED_GEM) { - char *tmp = xstrdup(fn); - const char *bn = basename(tmp); - size_t nvlen = strlen(bn) - 3; char *gem = rpmGetPath("%{__gem}", NULL); - char *gemspec = NULL; - char gemnameversion[nvlen]; - - rstrlcpy(gemnameversion, bn, nvlen); - gemspec = rpmGetPath("", gemnameversion, ".gemspec", NULL); - - rasprintf(&buf, "%s '%s' && %s spec '%s' --ruby > '%s'", - zipper, fn, gem, fn, gemspec); + + rasprintf(&buf, "%s %s && %s spec %s --ruby > %s.gemspec", + zipper, fn, gem, fn, bn); - free(gemspec); free(gem); - free(tmp); } else { - rasprintf(&buf, "%s%s '%s' %s", mkdir, zipper, fn, stripcd); + rasprintf(&buf, "%s%s %s %s", mkdir, zipper, fn, stripcd); } free(zipper); } else { - rasprintf(&buf, "%s %s %s '%s' %s", mkdir, tar, taropts, fn, stripcd); + rasprintf(&buf, "%s %s %s %s %s", mkdir, tar, taropts, fn, stripcd); } exit: @@ -247,7 +232,14 @@ int main(int argc, char *argv[]) int ec = EXIT_FAILURE; poptContext optCon = NULL; const char *arg = NULL; + char *arg_cpy = NULL; + const char *bnarg = "\"$1\""; + const char *fnarg = "\"$2\""; char *cmd = NULL; + archiveType *at = NULL; + int sr = 0; + char *bn = NULL; + char *stem; optCon = rpmcliInit(argc, argv, optionsTable); @@ -256,30 +248,56 @@ int main(int argc, char *argv[]) goto exit; } - cmd = extract ? doUntar(arg) : doUncompress(arg); + at = getArchiver(arg); + + arg_cpy = xstrdup(arg); + bn = basename(arg_cpy); + if ((stem = strrchr(bn, '.')) != 0) + *stem = 0; + + if (extract) { + if (dstpath) + sr = singleRoot(arg); + cmd = doUntar(at, sr, bnarg, fnarg); + } else { + cmd = doUncompress(at, fnarg); + } + if (cmd) { FILE *inp = NULL; - if (verbose || dryrun) - fprintf(stderr, "%s\n", cmd); + if (verbose || dryrun) { + char *drybn = NULL; + char *dryfn = NULL; + char *drycmd = NULL; + rasprintf(&drybn, "'%s'", bn); + rasprintf(&dryfn, "'%s'", arg); + drycmd = extract ? doUntar(at, sr, drybn, dryfn) : + doUncompress(at, dryfn); + fprintf(stderr, "%s\n", drycmd); + free(drycmd); + free(dryfn); + free(drybn); + } if (dryrun) { ec = EXIT_SUCCESS; goto exit; } - inp = popen(cmd, "r"); + inp = rpopen(cmd, bn, arg, NULL); if (inp) { int status, c; while ((c = fgetc(inp)) != EOF) fputc(c, stdout); - status = pclose(inp); + status = rpclose(inp); if (WIFEXITED(status) && WEXITSTATUS(status) == 0) ec = EXIT_SUCCESS; } } exit: + free(arg_cpy); free(cmd); rpmcliFini(optCon); return ec;
