diff options
author | Gilles Chehade <gilles@cvs.openbsd.org> | 2018-12-12 10:50:05 +0000 |
---|---|---|
committer | Gilles Chehade <gilles@cvs.openbsd.org> | 2018-12-12 10:50:05 +0000 |
commit | 96fb5329d8ece599579dc9d65b87c2006f10f4de (patch) | |
tree | ba2a42526b9ef9028f215c6841540d4d328e4996 | |
parent | 3c2964d35ae02366bee15ee310eedab2da060843 (diff) |
upon MAIL or RCPT errors, only trigger report_smtp_tx_{mail,rcpt} events if
error happened within an SMTP transaction.
-rw-r--r-- | usr.sbin/smtpd/smtp_session.c | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/usr.sbin/smtpd/smtp_session.c b/usr.sbin/smtpd/smtp_session.c index 3b7902138a6..fbf57ebea11 100644 --- a/usr.sbin/smtpd/smtp_session.c +++ b/usr.sbin/smtpd/smtp_session.c @@ -1,4 +1,4 @@ -/* $OpenBSD: smtp_session.c,v 1.372 2018/12/11 13:40:30 gilles Exp $ */ +/* $OpenBSD: smtp_session.c,v 1.373 2018/12/12 10:50:04 gilles Exp $ */ /* * Copyright (c) 2008 Gilles Chehade <gilles@poolp.org> @@ -2041,10 +2041,17 @@ smtp_reply(struct smtp_session *s, char *fmt, ...) break; case '5': case '4': - if (s->last_cmd == CMD_MAIL_FROM) - report_smtp_tx_mail("smtp-in", s->id, s->tx->msgid, s->cmd + 10, buf[0] == '4' ? -1 : 0); - else if (s->last_cmd == CMD_RCPT_TO) - report_smtp_tx_rcpt("smtp-in", s->id, s->tx->msgid, s->cmd + 8, buf[0] == '4' ? -1 : 0); + /* do not report smtp_tx_mail/smtp_tx_rcpt errors + * if they happened outside of a transaction. + */ + if (s->tx) { + if (s->last_cmd == CMD_MAIL_FROM) + report_smtp_tx_mail("smtp-in", s->id, s->tx->msgid, + s->cmd + 10, buf[0] == '4' ? -1 : 0); + else if (s->last_cmd == CMD_RCPT_TO) + report_smtp_tx_rcpt("smtp-in", s->id, + s->tx->msgid, s->cmd + 8, buf[0] == '4' ? -1 : 0); + } if (s->flags & SF_BADINPUT) { log_info("%016"PRIx64" smtp " |