summaryrefslogtreecommitdiff
path: root/usr/src/cmd/mailx/cmd1.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/cmd1.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/cmd1.c')
-rw-r--r--usr/src/cmd/mailx/cmd1.c34
1 files changed, 25 insertions, 9 deletions
diff --git a/usr/src/cmd/mailx/cmd1.c b/usr/src/cmd/mailx/cmd1.c
index 5cdb7ae465..38c9b7ab9b 100644
--- a/usr/src/cmd/mailx/cmd1.c
+++ b/usr/src/cmd/mailx/cmd1.c
@@ -19,6 +19,11 @@
*
* CDDL HEADER END
*/
+
+/*
+ * Copyright 2014 Joyent, Inc.
+ */
+
/*
* Copyright 2001 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
@@ -37,8 +42,7 @@
* contributors.
*/
-#pragma ident "%Z%%M% %I% %E% SMI"
-
+#include <err.h>
#include "rcv.h"
#include <locale.h>
@@ -213,10 +217,14 @@ printhead(int mesg)
char *fromline;
char pbuf[LINESIZE];
char name[LINESIZE];
- struct headline hl;
+ headline_t *hl;
register char *cp;
int showto;
+ if (headline_alloc(&hl) != 0) {
+ err(1, "could not allocate memory");
+ }
+
mp = &message[mesg-1];
ibuf = setinput(mp);
readline(ibuf, headline);
@@ -248,9 +256,14 @@ printhead(int mesg)
dispc = 'H';
if (mp->m_flag & MBOX)
dispc = 'M';
- parse(headline, &hl, pbuf);
- if (hl.l_date == NOSTR)
- hl.l_date = "<Unknown date>";
+ if (parse_headline(headline, hl) == -1) {
+ headline_reset(hl);
+ }
+ if (custr_len(hl->hl_date) == 0) {
+ if (custr_append(hl->hl_date, "<Unknown date>") != 0) {
+ err(1, "could not print header");
+ }
+ }
/*
* Netnews interface?
@@ -299,11 +312,14 @@ printhead(int mesg)
}
if (mp->m_text) {
printf("%16.16s %4ld/%-5ld %-.25s\n",
- hl.l_date, mp->m_lines, mp->m_size, subjline);
- } else {
- printf("%16.16s binary/%-5ld %-.25s\n", hl.l_date, mp->m_size,
+ custr_cstr(hl->hl_date), mp->m_lines, mp->m_size,
subjline);
+ } else {
+ printf("%16.16s binary/%-5ld %-.25s\n", custr_cstr(hl->hl_date),
+ mp->m_size, subjline);
}
+
+ headline_free(hl);
}
/*