summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorgilles <gilles@openbsd.org>2018-12-12 10:50:04 +0000
committergilles <gilles@openbsd.org>2018-12-12 10:50:04 +0000
commitb2f409062a761381c190a787184e8e343e4e0e28 (patch)
tree739fc845ac09b3525b4bf9a5cd054de4cfa753b1
parentEnable the rules doing more than one match at a time. This works since a while. (diff)
downloadwireguard-openbsd-b2f409062a761381c190a787184e8e343e4e0e28.tar.xz
wireguard-openbsd-b2f409062a761381c190a787184e8e343e4e0e28.zip
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.c17
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 "