From 51276332630d498712af296bd238e34b8daf037c Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Thu, 31 Oct 2002 13:45:55 +0000 Subject: Ready to ship stable. svn path=/trunk/; revision=3763 --- Makefile.in | 2 +- NEWS | 3 ++- sink.c | 46 +++++++++++++++++++++++++++++++++++++++------- smtp.c | 2 ++ 4 files changed, 44 insertions(+), 9 deletions(-) diff --git a/Makefile.in b/Makefile.in index de151629..e8eeb5ca 100644 --- a/Makefile.in +++ b/Makefile.in @@ -4,7 +4,7 @@ # So just uncomment all the lines marked QNX. PACKAGE = fetchmail -VERSION = 6.1.1 +VERSION = 6.1.2 # Ultrix 2.2 make doesn't expand the value of VPATH. srcdir = @srcdir@ diff --git a/NEWS b/NEWS index 2e54e93e..cd38b1e8 100644 --- a/NEWS +++ b/NEWS @@ -6,7 +6,8 @@ * Updated Turkish, German, Catalan, and Danish translation files. * Fix processing of POP3 messages with missing bodies. * Minor fixes by Sunil Shetye: fix generation of auth fail note, handle - unexpected SIGALRM, plug memory leak, handle lines beginning with '\0'. + unexpected SIGALRM, plug memory leak, handle lines beginning with '\0', + try to bulletproof error handling against read failures. fetchmail-6.1.1 (Fri Oct 18 14:53:51 EDT 2002), 22087 lines: diff --git a/sink.c b/sink.c index 5f484b17..a6f87aaa 100644 --- a/sink.c +++ b/sink.c @@ -770,6 +770,7 @@ static int open_smtp_sink(struct query *ctl, struct msgblk *msg, #endif /* EXPLICIT_BOUNCE_ON_BAD_ADDRESS */ int total_addresses; int force_transient_error = 0; + int smtp_err; /* * Compute ESMTP options. @@ -861,7 +862,12 @@ static int open_smtp_sink(struct query *ctl, struct msgblk *msg, ap = addr; } - if (SMTP_from(ctl->smtp_socket, ap, options) != SM_OK) + if ((smtp_err = SMTP_from(ctl->smtp_socket, ap, options)) == SM_UNRECOVERABLE) + { + smtp_close(ctl, 0); + return(PS_TRANSIENT); + } + if (smtp_err != SM_OK) { int err = handle_smtp_report(ctl, msg); @@ -883,7 +889,12 @@ static int open_smtp_sink(struct query *ctl, struct msgblk *msg, { const char *address; address = rcpt_address (ctl, idp->id, 1); - if (SMTP_rcpt(ctl->smtp_socket, address) == SM_OK) + if ((smtp_err = SMTP_rcpt(ctl->smtp_socket, address)) == SM_UNRECOVERABLE) + { + smtp_close(ctl, 0); + return(PS_TRANSIENT); + } + if (smtp_err == SM_OK) (*good_addresses)++; else { @@ -954,8 +965,13 @@ static int open_smtp_sink(struct query *ctl, struct msgblk *msg, SMTP_rset(ctl->smtp_socket); /* required by RFC1870 */ return(PS_REFUSED); } - if (SMTP_rcpt(ctl->smtp_socket, - rcpt_address (ctl, run.postmaster, 0)) != SM_OK) + if ((smtp_err = SMTP_rcpt(ctl->smtp_socket, + rcpt_address (ctl, run.postmaster, 0))) == SM_UNRECOVERABLE) + { + smtp_close(ctl, 0); + return(PS_TRANSIENT); + } + if (smtp_err != SM_OK) { report(stderr, GT_("can't even send to %s!\n"), run.postmaster); SMTP_rset(ctl->smtp_socket); /* required by RFC1870 */ @@ -970,7 +986,12 @@ static int open_smtp_sink(struct query *ctl, struct msgblk *msg, * Tell the listener we're ready to send data. * Some listeners (like zmailer) may return antispam errors here. */ - if (SMTP_data(ctl->smtp_socket) != SM_OK) + if ((smtp_err = SMTP_data(ctl->smtp_socket)) == SM_UNRECOVERABLE) + { + smtp_close(ctl, 0); + return(PS_TRANSIENT); + } + if (smtp_err != SM_OK) { int err = handle_smtp_report(ctl, msg); SMTP_rset(ctl->smtp_socket); /* stay on the safe side */ @@ -1240,6 +1261,7 @@ void release_sink(struct query *ctl) int close_sink(struct query *ctl, struct msgblk *msg, flag forward) /* perform end-of-message actions on the current output sink */ { + int smtp_err; if (ctl->mda) { int rc; @@ -1293,7 +1315,12 @@ int close_sink(struct query *ctl, struct msgblk *msg, flag forward) else if (forward) { /* write message terminator */ - if (SMTP_eom(ctl->smtp_socket) != SM_OK) + if ((smtp_err = SMTP_eom(ctl->smtp_socket)) == SM_UNRECOVERABLE) + { + smtp_close(ctl, 0); + return(FALSE); + } + if (smtp_err != SM_OK) { if (handle_smtp_report(ctl, msg) != PS_REFUSED) { @@ -1355,7 +1382,12 @@ int close_sink(struct query *ctl, struct msgblk *msg, flag forward) xalloca(responses, char **, sizeof(char *) * lmtp_responses); for (errors = i = 0; i < lmtp_responses; i++) { - if (SMTP_ok(ctl->smtp_socket) == SM_OK) + if ((smtp_err = SMTP_ok(ctl->smtp_socket)) == SM_UNRECOVERABLE) + { + smtp_close(ctl, 0); + return(FALSE); + } + if (smtp_err == SM_OK) responses[i] = (char *)NULL; else { diff --git a/smtp.c b/smtp.c index 021c868c..6c357571 100644 --- a/smtp.c +++ b/smtp.c @@ -343,6 +343,8 @@ int SMTP_ok(int sock) else if (smtp_response[3] != '-') return SM_ERROR; } + if (outlevel >= O_MONITOR) + report(stderr, GT_("smtp listener protocol error")); return SM_UNRECOVERABLE; } -- cgit v1.2.3