summaryrefslogtreecommitdiff
path: root/usr/src/cmd/mailx/receipt.c
diff options
context:
space:
mode:
authorJerry Jelinek <jerry.jelinek@joyent.com>2014-12-23 23:19:21 +0000
committerJerry Jelinek <jerry.jelinek@joyent.com>2014-12-23 23:19:21 +0000
commitaf9034a8036f884fc06874c445d85ac9f416f4fe (patch)
tree01ceaeec83dcf7e2bab07cbf2db7f40b7fcb5622 /usr/src/cmd/mailx/receipt.c
parent8af96fbb6bb47d4566bcfef02a8e551164eb2208 (diff)
parent5422785d352a2bb398daceab3d1898a8aa64d006 (diff)
downloadillumos-joyent-release-20141225.tar.gz
[illumos-gate merge]20141225release-20141225
commit 5422785d352a2bb398daceab3d1898a8aa64d006 5481 CVE-2012-1750 mailx(1) tilde expansion vulnerability 5482 CVE-2014-7844, CVE-2004-2771 - more mailx(1) woes commit 196c7f05d2deba7404e90ad67f3861185c78ca2d 5480 CVE-2012-3165 mailx(1) buffer overflow vulnerability
Diffstat (limited to 'usr/src/cmd/mailx/receipt.c')
-rw-r--r--usr/src/cmd/mailx/receipt.c26
1 files changed, 21 insertions, 5 deletions
diff --git a/usr/src/cmd/mailx/receipt.c b/usr/src/cmd/mailx/receipt.c
index 2a128d6a91..0b6b9296fc 100644
--- a/usr/src/cmd/mailx/receipt.c
+++ b/usr/src/cmd/mailx/receipt.c
@@ -19,6 +19,11 @@
*
* CDDL HEADER END
*/
+
+/*
+ * Copyright 2014 Joyent, Inc.
+ */
+
/*
* Copyright 1998 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
@@ -38,7 +43,7 @@
* contributors.
*/
-#pragma ident "%Z%%M% %I% %E% SMI"
+#include <err.h>
#include "rcv.h"
@@ -47,12 +52,12 @@ static int icsubstr(char *s1, char *s2);
void
receipt(struct message *mp)
{
- struct headline hl;
char head[LINESIZE];
char buf[BUFSIZ];
FILE *pp, *fp;
char *mail, *s;
+
if ((mail = value("sendmail")) == 0)
#ifdef SENDMAIL
mail = SENDMAIL;
@@ -63,16 +68,27 @@ receipt(struct message *mp)
|| icsubstr(hfield(">to", mp, addto), "/receipt")) {
snprintf(buf, sizeof (buf), "%s %s", mail, skin(nameof(mp)));
if (pp = npopen(buf, "w")) {
+ headline_t *hl;
+
+ if (headline_alloc(&hl) != 0) {
+ err(1, "could not allocate memory");
+ }
+
fp = setinput(mp);
readline(fp, head);
- parse(head, &hl, buf);
- if (hl.l_date != NOSTR)
- fprintf(pp, "Original-Date: %s\n", hl.l_date);
+ if (parse_headline(head, hl) != 0) {
+ headline_reset(hl);
+ }
+ if (custr_len(hl->hl_date) > 0) {
+ fprintf(pp, "Original-Date: %s\n",
+ custr_cstr(hl->hl_date));
+ }
if (s = hfield("message-id", mp, addone))
fprintf(pp, "Original-Message-ID: %s\n", s);
s = hfield("subject", mp, addone);
fprintf(pp, "Subject: RR: %s\n", s ? s : "(none)");
npclose(pp);
+ headline_free(hl);
}
}
}