File 0002-unpack-Disable-option-processing-for-email-addresses.patch of Package mailx

From e34e2ac67b80497080ebecccec40c3b61456167d Mon Sep 17 00:00:00 2001
From: Florian Weimer <fweimer@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