From ad9e01054310fa109d342f7565eba91eef3afd94 Mon Sep 17 00:00:00 2001 From: Gilles Chehade Date: Mon, 16 May 2016 19:25:06 +0000 Subject: fix logic in error code path of smtp state machine that can lead to an invalid state ending in fatal(), while at it plug a file pointer leak. ok eric@, millert@ --- usr.sbin/smtpd/filter.c | 4 +++- usr.sbin/smtpd/smtp_session.c | 5 ++++- 2 files changed, 7 insertions(+), 2 deletions(-) (limited to 'usr.sbin') diff --git a/usr.sbin/smtpd/filter.c b/usr.sbin/smtpd/filter.c index c927e855046..bc880ee4cf1 100644 --- a/usr.sbin/smtpd/filter.c +++ b/usr.sbin/smtpd/filter.c @@ -1,4 +1,4 @@ -/* $OpenBSD: filter.c,v 1.17 2016/03/25 15:06:58 krw Exp $ */ +/* $OpenBSD: filter.c,v 1.18 2016/05/16 19:25:05 gilles Exp $ */ /* * Copyright (c) 2011 Gilles Chehade @@ -297,6 +297,8 @@ filter_event(uint64_t id, int event) if (event == EVENT_DISCONNECT) { io_clear(&s->iev); iobuf_clear(&s->ibuf); + if (s->ofile) + fclose(s->ofile); free(s); } } diff --git a/usr.sbin/smtpd/smtp_session.c b/usr.sbin/smtpd/smtp_session.c index 2146037c532..f08af48206c 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.270 2016/05/08 20:24:01 millert Exp $ */ +/* $OpenBSD: smtp_session.c,v 1.271 2016/05/16 19:25:05 gilles Exp $ */ /* * Copyright (c) 2008 Gilles Chehade @@ -1144,6 +1144,7 @@ smtp_filter_response(uint64_t id, int query, int status, uint32_t code, case QUERY_EOM: if (status != FILTER_OK) { + tree_pop(&wait_filter_data, s->id); smtp_filter_rollback(s); code = code ? code : 530; line = line ? line : "Message rejected"; @@ -1450,6 +1451,8 @@ smtp_data_io_done(struct smtp_session *s) if (s->msgflags & MF_ERROR) { + tree_pop(&wait_filter_data, s->id); + smtp_filter_rollback(s); smtp_queue_rollback(s); -- cgit v1.2.3