[packages/mailx] Rel 9. Backport Red Hat security fixes, fix parallel build race.

arekm arekm at pld-linux.org
Thu Oct 29 09:41:39 CET 2026


commit b1c6a23944e62a9f0f433144b010c7c198dd063f
Author: Arkadiusz Miśkiewicz <arekm at maven.pl>
Date:   Thu Oct 29 07:23:34 2026 +0100

    Rel 9. Backport Red Hat security fixes, fix parallel build race.
    
    Fixes CVE-2014-7844, CVE-2004-2771.

 mailx-expandaddr.patch          |  68 ++++++++++++++++++++++++
 mailx-fname-null.patch          |  14 +++++
 mailx-makeconfig-parallel.patch |  18 +++++++
 mailx-unpack-no-options.patch   |  78 ++++++++++++++++++++++++++++
 mailx-wordexp-nocmd.patch       |  29 +++++++++++
 mailx-wordexp-required.patch    | 112 ++++++++++++++++++++++++++++++++++++++++
 mailx.spec                      |  20 +++++--
 7 files changed, 336 insertions(+), 3 deletions(-)
---
diff --git a/mailx.spec b/mailx.spec
index 293edae..9f65bb6 100644
--- a/mailx.spec
+++ b/mailx.spec
@@ -6,10 +6,10 @@ Summary:	An enhanced implementation of the mailx command
 Summary(pl.UTF-8):	Rozszerzona implementacja komendy mailx
 Name:		mailx
 Version:	12.4
-Release:	8
+Release:	9
 License:	BSD
 Group:		Applications/Mail
-Source0:	http://downloads.sourceforge.net/heirloom/%{name}-%{version}.tar.bz2
+Source0:	https://downloads.sourceforge.net/heirloom/%{name}-%{version}.tar.bz2
 # Source0-md5:	0c93759e34200eb56a0e7c464680a54a
 Patch0:		%{name}-bsdcompat.patch
 Patch1:		%{name}-use-krb5-gss.patch
@@ -18,7 +18,13 @@ Patch3:		%{name}-openssl.patch
 Patch4:		%{name}-ipv6.patch
 Patch5:		%{name}-pager.patch
 Patch6:		openssl.patch
-URL:		http://heirloom.sourceforge.net/mailx.html
+Patch7:		%{name}-expandaddr.patch
+Patch8:		%{name}-unpack-no-options.patch
+Patch9:		%{name}-wordexp-required.patch
+Patch10:	%{name}-wordexp-nocmd.patch
+Patch11:	%{name}-makeconfig-parallel.patch
+Patch12:	%{name}-fname-null.patch
+URL:		https://heirloom.sourceforge.net/mailx.html
 %{?with_kerberos5:BuildRequires:	heimdal-devel}
 BuildRequires:	openssl-devel >= 0.9.7d
 Obsoletes:	nail
@@ -49,13 +55,21 @@ IMAP, wątkowanie wiadomości, punktacja i filtrowanie.
 %patch -P4 -p1
 %patch -P5 -p1
 %patch -P6 -p1
+%patch -P7 -p1
+%patch -P8 -p1
+%patch -P9 -p1
+%patch -P10 -p1
+%patch -P11 -p1
+%patch -P12 -p1
 
 %{!?with_kerberos5:sed -i -e 's#gssapi.h#puke.h#g' makeconfig}
 
 %build
 %{__make} \
 	CC="%{__cc}" \
+	CPPFLAGS="%{rpmcppflags}" \
 	CFLAGS="%{rpmcflags}" \
+	LDFLAGS="%{rpmldflags}" \
 	MAILRC=/etc/mail.rc \
 	MAILSPOOL=/var/mail \
 	SENDMAIL=/usr/lib/sendmail
diff --git a/mailx-expandaddr.patch b/mailx-expandaddr.patch
new file mode 100644
index 0000000..beaf291
--- /dev/null
+++ b/mailx-expandaddr.patch
@@ -0,0 +1,68 @@
+CVE-2014-7844: pipe/file recipients only with "set expandaddr"
+https://sources.debian.org/data/main/h/heirloom-mailx/12.4-2+deb6u1/debian/patches/0011-outof-Introduce-expandaddr-flag.patch
+
+From 9984ae5cb0ea0d61df1612b06952a61323c083d9 Mon Sep 17 00:00:00 2001
+From: Florian Weimer <fweimer at redhat.com>
+Date: Mon, 17 Nov 2014 11:13:38 +0100
+Subject: [PATCH 1/4] outof: Introduce expandaddr flag
+
+Document that address expansion is disabled unless the expandaddr
+binary option is set.
+
+This has been assigned CVE-2014-7844 for BSD mailx, but it is not
+a vulnerability in Heirloom mailx because this feature was documented.
+---
+ mailx.1 | 14 ++++++++++++++
+ names.c |  3 +++
+ 2 files changed, 17 insertions(+)
+
+diff --git a/mailx.1 b/mailx.1
+index 70a7859..22a171b 100644
+--- a/mailx.1
++++ b/mailx.1
+@@ -656,6 +656,14 @@ but any reply returned to the machine
+ will have the system wide alias expanded
+ as all mail goes through sendmail.
+ .SS "Recipient address specifications"
++If the
++.I expandaddr
++option is not set (the default), recipient addresses must be names of
++local mailboxes or Internet mail addresses.
++.PP
++If the
++.I expandaddr
++option is set, the following rules apply:
+ When an address is used to name a recipient
+ (in any of To, Cc, or Bcc),
+ names of local mail folders
+@@ -2391,6 +2399,12 @@ and exits immediately.
+ If this option is set,
+ \fImailx\fR starts even with an empty mailbox.
+ .TP
++.B expandaddr
++Causes
++.I mailx
++to expand message recipient addresses, as explained in the section,
++Recipient address specifications.
++.TP
+ .B flipr
+ Exchanges the
+ .I Respond
+diff --git a/names.c b/names.c
+index 66e976b..c69560f 100644
+--- a/names.c
++++ b/names.c
+@@ -268,6 +268,9 @@ outof(struct name *names, FILE *fo, struct header *hp)
+ 	FILE *fout, *fin;
+ 	int ispipe;
+ 
++	if (value("expandaddr") == NULL)
++		return names;
++
+ 	top = names;
+ 	np = names;
+ 	time(&now);
+-- 
+1.9.3
+
+
diff --git a/mailx-fname-null.patch b/mailx-fname-null.patch
new file mode 100644
index 0000000..52ab6e5
--- /dev/null
+++ b/mailx-fname-null.patch
@@ -0,0 +1,14 @@
+outof: NULL deref (segfault) when expand() rejects a file recipient, e.g. a wordexp syntax error
+https://gitlab.com/redhat/centos-stream/rpms/mailx/-/raw/c8s/mailx-12.5-fname-null.patch
+
+--- mailx-12.4/names.c.orig
++++ mailx-12.4/names.c
+@@ -360,7 +360,7 @@
+ 			free_child(pid);
+ 		} else {
+ 			int f;
+-			if ((fout = Zopen(fname, "a", NULL)) == NULL) {
++			if ((fname == NULL) || ((fout = Zopen(fname, "a", NULL)) == NULL)) {
+ 				perror(fname);
+ 				senderr++;
+ 				goto cant;
diff --git a/mailx-makeconfig-parallel.patch b/mailx-makeconfig-parallel.patch
new file mode 100644
index 0000000..5986dec
--- /dev/null
+++ b/mailx-makeconfig-parallel.patch
@@ -0,0 +1,18 @@
+"config.h LIBS: makeconfig" runs makeconfig once per target under make -j; the two
+runs share temp files and corrupt LIBS (link fails with "cannot find empty")
+
+--- mailx-12.4/Makefile.orig	2026-10-29 03:19:34.922361619 +0100
++++ mailx-12.4/Makefile	2026-10-29 03:19:34.928513107 +0100
+@@ -96,9 +96,11 @@
+ md5.o imap.o hmac.o smtp.o aux.o pop3.o junk.o: md5.h
+ nss.o: nsserr.c
+ 
+-config.h LIBS: makeconfig
++config.h: makeconfig
+ 	$(SHELL) ./makeconfig
+ 
++LIBS: config.h
++
+ install: all
+ 	test -d $(DESTDIR)$(BINDIR) || mkdir -p $(DESTDIR)$(BINDIR)
+ 	$(UCBINSTALL) -c mailx $(DESTDIR)$(BINDIR)/mailx
diff --git a/mailx-unpack-no-options.patch b/mailx-unpack-no-options.patch
new file mode 100644
index 0000000..fe5d90c
--- /dev/null
+++ b/mailx-unpack-no-options.patch
@@ -0,0 +1,78 @@
+CVE-2014-7844: recipients passed to sendmail after "--"
+https://sources.debian.org/data/main/h/heirloom-mailx/12.4-2+deb6u1/debian/patches/0012-unpack-Disable-option-processing-for-email-addresses.patch
+
+From e34e2ac67b80497080ebecccec40c3b61456167d Mon Sep 17 00:00:00 2001
+From: Florian Weimer <fweimer at redhat.com>
+Date: Mon, 17 Nov 2014 11:14:06 +0100
+Subject: [PATCH 2/4] unpack: Disable option processing for email addresses
+ when calling sendmail
+
+---
+ extern.h  | 2 +-
+ names.c   | 8 ++++++--
+ sendout.c | 2 +-
+ 3 files changed, 8 insertions(+), 4 deletions(-)
+
+diff --git a/extern.h b/extern.h
+index 6b85ba0..8873fe8 100644
+--- a/extern.h
++++ b/extern.h
+@@ -396,7 +396,7 @@ struct name *outof(struct name *names, FILE *fo, struct header *hp);
+ int is_fileaddr(char *name);
+ struct name *usermap(struct name *names);
+ struct name *cat(struct name *n1, struct name *n2);
+-char **unpack(struct name *np);
++char **unpack(struct name *smopts, struct name *np);
+ struct name *elide(struct name *names);
+ int count(struct name *np);
+ struct name *delete_alternates(struct name *np);
+diff --git a/names.c b/names.c
+index c69560f..45bbaed 100644
+--- a/names.c
++++ b/names.c
+@@ -549,7 +549,7 @@ cat(struct name *n1, struct name *n2)
+  * Return an error if the name list won't fit.
+  */
+ char **
+-unpack(struct name *np)
++unpack(struct name *smopts, struct name *np)
+ {
+ 	char **ap, **top;
+ 	struct name *n;
+@@ -564,7 +564,7 @@ unpack(struct name *np)
+ 	 * the terminating 0 pointer.  Additional spots may be needed
+ 	 * to pass along -f to the host mailer.
+ 	 */
+-	extra = 2;
++	extra = 3 + count(smopts);
+ 	extra++;
+ 	metoo = value("metoo") != NULL;
+ 	if (metoo)
+@@ -581,6 +581,10 @@ unpack(struct name *np)
+ 		*ap++ = "-m";
+ 	if (verbose)
+ 		*ap++ = "-v";
++	for (; smopts != NULL; smopts = smopts->n_flink)
++		if ((smopts->n_type & GDEL) == 0)
++			*ap++ = smopts->n_name;
++	*ap++ = "--";
+ 	for (; n != NULL; n = n->n_flink)
+ 		if ((n->n_type & GDEL) == 0)
+ 			*ap++ = n->n_name;
+diff --git a/sendout.c b/sendout.c
+index 7b7f2eb..c52f15d 100644
+--- a/sendout.c
++++ b/sendout.c
+@@ -835,7 +835,7 @@ start_mta(struct name *to, struct name *mailargs, FILE *input,
+ #endif	/* HAVE_SOCKETS */
+ 
+ 	if ((smtp = value("smtp")) == NULL) {
+-		args = unpack(cat(mailargs, to));
++		args = unpack(mailargs, to);
+ 		if (debug || value("debug")) {
+ 			printf(catgets(catd, CATSET, 181,
+ 					"Sendmail arguments:"));
+-- 
+1.9.3
+
+
diff --git a/mailx-wordexp-nocmd.patch b/mailx-wordexp-nocmd.patch
new file mode 100644
index 0000000..60961b4
--- /dev/null
+++ b/mailx-wordexp-nocmd.patch
@@ -0,0 +1,29 @@
+CVE-2004-2771: no command substitution in file name expansion
+https://sources.debian.org/data/main/h/heirloom-mailx/12.4-2+deb6u1/debian/patches/0014-globname-Invoke-wordexp-with-WRDE_NOCMD.patch
+
+From 73fefa0c1ac70043ec84f2d8b8f9f683213f168d Mon Sep 17 00:00:00 2001
+From: Florian Weimer <fweimer at redhat.com>
+Date: Mon, 17 Nov 2014 13:11:32 +0100
+Subject: [PATCH 4/4] globname: Invoke wordexp with WRDE_NOCMD (CVE-2004-2771)
+
+---
+ fio.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/fio.c b/fio.c
+index 1529236..774a204 100644
+--- a/fio.c
++++ b/fio.c
+@@ -497,7 +497,7 @@ globname(char *name)
+ 	sigemptyset(&nset);
+ 	sigaddset(&nset, SIGCHLD);
+ 	sigprocmask(SIG_BLOCK, &nset, NULL);
+-	i = wordexp(name, &we, 0);
++	i = wordexp(name, &we, WRDE_NOCMD);
+ 	sigprocmask(SIG_UNBLOCK, &nset, NULL);
+ 	switch (i) {
+ 	case 0:
+-- 
+1.9.3
+
+
diff --git a/mailx-wordexp-required.patch b/mailx-wordexp-required.patch
new file mode 100644
index 0000000..cb9e6fc
--- /dev/null
+++ b/mailx-wordexp-required.patch
@@ -0,0 +1,112 @@
+drop the "$SHELL -c echo" globbing fallback, needed by the CVE-2004-2771 fix
+https://sources.debian.org/data/main/h/heirloom-mailx/12.4-2+deb6u1/debian/patches/0013-fio.c-Unconditionally-require-wordexp-support.patch
+
+From 2bae8ecf04ec2ba6bb9f0af5b80485dd0edb427d Mon Sep 17 00:00:00 2001
+From: Florian Weimer <fweimer at redhat.com>
+Date: Mon, 17 Nov 2014 12:48:25 +0100
+Subject: [PATCH 3/4] fio.c: Unconditionally require wordexp support
+
+---
+ fio.c | 67 +++++--------------------------------------------------------------
+ 1 file changed, 5 insertions(+), 62 deletions(-)
+
+diff --git a/fio.c b/fio.c
+index 65e8f10..1529236 100644
+--- a/fio.c
++++ b/fio.c
+@@ -43,12 +43,15 @@ static char sccsid[] = "@(#)fio.c	2.76 (gritter) 9/16/09";
+ #endif /* not lint */
+ 
+ #include "rcv.h"
++
++#ifndef HAVE_WORDEXP
++#error wordexp support is required
++#endif
++
+ #include <sys/stat.h>
+ #include <sys/file.h>
+ #include <sys/wait.h>
+-#ifdef	HAVE_WORDEXP
+ #include <wordexp.h>
+-#endif	/* HAVE_WORDEXP */
+ #include <unistd.h>
+ 
+ #if defined (USE_NSS)
+@@ -481,7 +484,6 @@ next:
+ static char *
+ globname(char *name)
+ {
+-#ifdef	HAVE_WORDEXP
+ 	wordexp_t we;
+ 	char *cp;
+ 	sigset_t nset;
+@@ -527,65 +529,6 @@ globname(char *name)
+ 	}
+ 	wordfree(&we);
+ 	return cp;
+-#else	/* !HAVE_WORDEXP */
+-	char xname[PATHSIZE];
+-	char cmdbuf[PATHSIZE];		/* also used for file names */
+-	int pid, l;
+-	char *cp, *shell;
+-	int pivec[2];
+-	extern int wait_status;
+-	struct stat sbuf;
+-
+-	if (pipe(pivec) < 0) {
+-		perror("pipe");
+-		return name;
+-	}
+-	snprintf(cmdbuf, sizeof cmdbuf, "echo %s", name);
+-	if ((shell = value("SHELL")) == NULL)
+-		shell = SHELL;
+-	pid = start_command(shell, 0, -1, pivec[1], "-c", cmdbuf, NULL);
+-	if (pid < 0) {
+-		close(pivec[0]);
+-		close(pivec[1]);
+-		return NULL;
+-	}
+-	close(pivec[1]);
+-again:
+-	l = read(pivec[0], xname, sizeof xname);
+-	if (l < 0) {
+-		if (errno == EINTR)
+-			goto again;
+-		perror("read");
+-		close(pivec[0]);
+-		return NULL;
+-	}
+-	close(pivec[0]);
+-	if (wait_child(pid) < 0 && WTERMSIG(wait_status) != SIGPIPE) {
+-		fprintf(stderr, catgets(catd, CATSET, 81,
+-				"\"%s\": Expansion failed.\n"), name);
+-		return NULL;
+-	}
+-	if (l == 0) {
+-		fprintf(stderr, catgets(catd, CATSET, 82,
+-					"\"%s\": No match.\n"), name);
+-		return NULL;
+-	}
+-	if (l == sizeof xname) {
+-		fprintf(stderr, catgets(catd, CATSET, 83,
+-				"\"%s\": Expansion buffer overflow.\n"), name);
+-		return NULL;
+-	}
+-	xname[l] = 0;
+-	for (cp = &xname[l-1]; *cp == '\n' && cp > xname; cp--)
+-		;
+-	cp[1] = '\0';
+-	if (strchr(xname, ' ') && stat(xname, &sbuf) < 0) {
+-		fprintf(stderr, catgets(catd, CATSET, 84,
+-				"\"%s\": Ambiguous.\n"), name);
+-		return NULL;
+-	}
+-	return savestr(xname);
+-#endif	/* !HAVE_WORDEXP */
+ }
+ 
+ /*
+-- 
+1.9.3
+
+
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/packages/mailx.git/commitdiff/b1c6a23944e62a9f0f433144b010c7c198dd063f



More information about the pld-cvs-commit mailing list