diff options
Diffstat (limited to 'contrib/sendmail/src/headers.c')
-rw-r--r-- | contrib/sendmail/src/headers.c | 69 |
1 files changed, 41 insertions, 28 deletions
diff --git a/contrib/sendmail/src/headers.c b/contrib/sendmail/src/headers.c index ec0d376..0bd0c49 100644 --- a/contrib/sendmail/src/headers.c +++ b/contrib/sendmail/src/headers.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998-2004 Sendmail, Inc. and its suppliers. + * Copyright (c) 1998-2004, 2006 Sendmail, Inc. and its suppliers. * All rights reserved. * Copyright (c) 1983, 1995-1997 Eric P. Allman. All rights reserved. * Copyright (c) 1988, 1993 @@ -14,12 +14,12 @@ #include <sendmail.h> -SM_RCSID("@(#)$Id: headers.c,v 8.287 2004/12/03 18:29:51 ca Exp $") +SM_RCSID("@(#)$Id: headers.c,v 8.290 2006/02/25 02:16:52 ca Exp $") static HDR *allocheader __P((char *, char *, int, SM_RPOOL_T *)); static size_t fix_mime_header __P((HDR *, ENVELOPE *)); static int priencode __P((char *)); -static void put_vanilla_header __P((HDR *, char *, MCI *)); +static bool put_vanilla_header __P((HDR *, char *, MCI *)); /* ** SETUPHEADERS -- initialize headers in symbol table @@ -994,7 +994,6 @@ logsender(e, msgid) char *name; register char *sbp; register char *p; - int l; char hbuf[MAXNAME + 1]; char sbuf[MAXLINE + 1]; char mbuf[MAXNAME + 1]; @@ -1003,6 +1002,8 @@ logsender(e, msgid) /* XXX do we still need this? sm_syslog() replaces control chars */ if (msgid != NULL) { + size_t l; + l = strlen(msgid); if (l > sizeof mbuf - 1) l = sizeof mbuf - 1; @@ -1542,13 +1543,13 @@ crackaddr(addr, e) ** flags -- MIME conversion flags. ** ** Returns: -** none. +** success ** ** Side Effects: ** none. */ -void +bool putheader(mci, hdr, e, flags) register MCI *mci; HDR *hdr; @@ -1683,7 +1684,8 @@ putheader(mci, hdr, e, flags) { if (tTd(34, 11)) sm_dprintf("\n"); - put_vanilla_header(h, p, mci); + if (!put_vanilla_header(h, p, mci)) + goto writeerr; continue; } @@ -1742,7 +1744,8 @@ putheader(mci, hdr, e, flags) /* no other recipient headers: truncate value */ (void) sm_strlcpyn(obuf, sizeof obuf, 2, h->h_field, ":"); - putline(obuf, mci); + if (!putline(obuf, mci)) + goto writeerr; } continue; } @@ -1761,7 +1764,8 @@ putheader(mci, hdr, e, flags) } else { - put_vanilla_header(h, p, mci); + if (!put_vanilla_header(h, p, mci)) + goto writeerr; } } @@ -1778,18 +1782,25 @@ putheader(mci, hdr, e, flags) !bitset(MCIF_CVT8TO7|MCIF_CVT7TO8|MCIF_INMIME, mci->mci_flags) && hvalue("MIME-Version", e->e_header) == NULL) { - putline("MIME-Version: 1.0", mci); + if (!putline("MIME-Version: 1.0", mci)) + goto writeerr; if (hvalue("Content-Type", e->e_header) == NULL) { (void) sm_snprintf(obuf, sizeof obuf, "Content-Type: text/plain; charset=%s", defcharset(e)); - putline(obuf, mci); + if (!putline(obuf, mci)) + goto writeerr; } - if (hvalue("Content-Transfer-Encoding", e->e_header) == NULL) - putline("Content-Transfer-Encoding: 8bit", mci); + if (hvalue("Content-Transfer-Encoding", e->e_header) == NULL + && !putline("Content-Transfer-Encoding: 8bit", mci)) + goto writeerr; } #endif /* MIME8TO7 */ + return true; + + writeerr: + return false; } /* ** PUT_VANILLA_HEADER -- output a fairly ordinary header @@ -1800,10 +1811,10 @@ putheader(mci, hdr, e, flags) ** mci -- the connection info for output ** ** Returns: -** none. +** success */ -static void +static bool put_vanilla_header(h, v, mci) HDR *h; char *v; @@ -1834,7 +1845,8 @@ put_vanilla_header(h, v, mci) l = SPACELEFT(obuf, obp) - 1; (void) sm_snprintf(obp, SPACELEFT(obuf, obp), "%.*s", l, v); - putxline(obuf, strlen(obuf), mci, putflags); + if (!putxline(obuf, strlen(obuf), mci, putflags)) + goto writeerr; v += l + 1; obp = obuf; if (*v != ' ' && *v != '\t') @@ -1844,7 +1856,10 @@ put_vanilla_header(h, v, mci) /* XXX This is broken for SPACELEFT()==0 */ (void) sm_snprintf(obp, SPACELEFT(obuf, obp), "%.*s", (int) (SPACELEFT(obuf, obp) - 1), v); - putxline(obuf, strlen(obuf), mci, putflags); + return putxline(obuf, strlen(obuf), mci, putflags); + + writeerr: + return false; } /* ** COMMAIZE -- output a header field, making a comma-translated list. @@ -1857,13 +1872,13 @@ put_vanilla_header(h, v, mci) ** e -- the envelope containing the message. ** ** Returns: -** none. +** success ** ** Side Effects: ** outputs "p" to file "fp". */ -void +bool commaize(h, p, oldstyle, mci, e) register HDR *h; register char *p; @@ -2002,13 +2017,6 @@ commaize(h, p, oldstyle, mci, e) } name = denlstring(name, false, true); - /* - ** record data progress so DNS timeouts - ** don't cause DATA timeouts - */ - - DataProgress = true; - /* output the name with nice formatting */ opos += strlen(name); if (!firstone) @@ -2016,7 +2024,8 @@ commaize(h, p, oldstyle, mci, e) if (opos > omax && !firstone) { (void) sm_strlcpy(obp, ",\n", SPACELEFT(obuf, obp)); - putxline(obuf, strlen(obuf), mci, putflags); + if (!putxline(obuf, strlen(obuf), mci, putflags)) + goto writeerr; obp = obuf; (void) sm_strlcpy(obp, " ", sizeof obuf); opos = strlen(obp); @@ -2038,8 +2047,12 @@ commaize(h, p, oldstyle, mci, e) *obp = '\0'; else obuf[sizeof obuf - 1] = '\0'; - putxline(obuf, strlen(obuf), mci, putflags); + return putxline(obuf, strlen(obuf), mci, putflags); + + writeerr: + return false; } + /* ** COPYHEADER -- copy header list ** |