diff options
Diffstat (limited to 'contrib/sendmail/src/savemail.c')
-rw-r--r-- | contrib/sendmail/src/savemail.c | 67 |
1 files changed, 55 insertions, 12 deletions
diff --git a/contrib/sendmail/src/savemail.c b/contrib/sendmail/src/savemail.c index 2413281..33a897a 100644 --- a/contrib/sendmail/src/savemail.c +++ b/contrib/sendmail/src/savemail.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998-2003, 2006 Sendmail, Inc. and its suppliers. + * Copyright (c) 1998-2003, 2006, 2012, 2013 Sendmail, Inc. and its suppliers. * All rights reserved. * Copyright (c) 1983, 1995-1997 Eric P. Allman. All rights reserved. * Copyright (c) 1988, 1993 @@ -13,7 +13,7 @@ #include <sendmail.h> -SM_RCSID("@(#)$Id: savemail.c,v 8.315 2012/02/27 17:43:03 gshapiro Exp $") +SM_RCSID("@(#)$Id: savemail.c,v 8.318 2013/03/12 15:24:54 ca Exp $") static bool errbody __P((MCI *, ENVELOPE *, char *)); static bool pruneroute __P((char *)); @@ -204,7 +204,7 @@ savemail(e, sendbody) (void) sm_io_fprintf(smioout, SM_TIME_DEFAULT, "Transcript follows:\r\n"); while (sm_io_fgets(e->e_xfp, SM_TIME_DEFAULT, - buf, sizeof(buf)) != NULL && + buf, sizeof(buf)) >= 0 && !sm_io_error(smioout)) (void) sm_io_fputs(smioout, SM_TIME_DEFAULT, @@ -866,7 +866,7 @@ errbody(mci, e, separator) if (xfile != NULL) { while (sm_io_fgets(xfile, SM_TIME_DEFAULT, buf, - sizeof(buf)) != NULL) + sizeof(buf)) >= 0) { int lbs; bool putok; @@ -1042,18 +1042,20 @@ errbody(mci, e, separator) } else { + int blen; + printheader = true; (void) bfrewind(e->e_parent->e_xfp); if (e->e_xfp != NULL) (void) sm_io_flush(e->e_xfp, SM_TIME_DEFAULT); - while (sm_io_fgets(e->e_parent->e_xfp, SM_TIME_DEFAULT, buf, - sizeof(buf)) != NULL) + while ((blen = sm_io_fgets(e->e_parent->e_xfp, SM_TIME_DEFAULT, + buf, sizeof(buf))) >= 0) { if (printheader && !putline(" ----- Transcript of session follows -----\n", mci)) goto writeerr; printheader = false; - if (!putline(buf, mci)) + if (!putxline(buf, blen, mci, PXLF_MAPFROM)) goto writeerr; } } @@ -1174,11 +1176,24 @@ errbody(mci, e, separator) /* Original-Recipient: -- passed from on high */ if (q->q_orcpt != NULL) { - (void) sm_snprintf(buf, sizeof(buf), - "Original-Recipient: %.800s", - q->q_orcpt); - if (!putline(buf, mci)) - goto writeerr; + p = strchr(q->q_orcpt, ';'); + + /* + ** p == NULL shouldn't happen due to + ** check in srvrsmtp.c + ** we could log an error in this case. + */ + + if (p != NULL) + { + *p = '\0'; + (void) sm_snprintf(buf, sizeof(buf), + "Original-Recipient: %.100s;%.700s", + q->q_orcpt, xuntextify(p + 1)); + *p = ';'; + if (!putline(buf, mci)) + goto writeerr; + } } /* Figure out actual recipient */ @@ -1682,6 +1697,34 @@ xtextok(s) } return true; } + +/* +** ISATOM -- check if a string is an "atom" +** +** Parameters: +** s -- the string to check. +** +** Returns: +** true -- iff s is an atom +*/ + +bool +isatom(s) + const char *s; +{ + int c; + + if (s == NULL || *s == '\0') + return false; + while ((c = *s++) != '\0') + { + if (strchr("()<>@,;:\\.[]\"", c) != NULL) + return false; + if (c < '!' || c > '~') + return false; + } + return true; +} /* ** PRUNEROUTE -- prune an RFC-822 source route ** |