diff options
author | Gilles Chehade <gilles@cvs.openbsd.org> | 2009-05-31 18:34:49 +0000 |
---|---|---|
committer | Gilles Chehade <gilles@cvs.openbsd.org> | 2009-05-31 18:34:49 +0000 |
commit | 56a9092e1314d2e35e0a15144c5959d90769c01c (patch) | |
tree | 12e4fa043c4e76ada1f035cf6b893709823be206 | |
parent | 9e549b6118ce4a33059dc512ba3b70a21f384d5a (diff) |
when entering mta_connect() reset session fd to -1
when connect timesout and we close the fd, reset session fd to -1
in session_destroy(), only attempt to close session fd if != -1
fixes a fatal in session_destroy() which happened because we closed a fd
after a timeout, but the session still assumed the fd to be opened.
-rw-r--r-- | usr.sbin/smtpd/mta.c | 5 | ||||
-rw-r--r-- | usr.sbin/smtpd/smtp_session.c | 4 |
2 files changed, 6 insertions, 3 deletions
diff --git a/usr.sbin/smtpd/mta.c b/usr.sbin/smtpd/mta.c index cb5a1a20db5..1ecc66748ef 100644 --- a/usr.sbin/smtpd/mta.c +++ b/usr.sbin/smtpd/mta.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mta.c,v 1.53 2009/05/30 23:53:41 gilles Exp $ */ +/* $OpenBSD: mta.c,v 1.54 2009/05/31 18:34:48 gilles Exp $ */ /* * Copyright (c) 2008 Pierre-Yves Ritschard <pyr@openbsd.org> @@ -605,6 +605,8 @@ mta_connect(struct session *sessionp) struct linger lng; struct mxhost *mxhost; + sessionp->s_fd = -1; + mxhost = TAILQ_FIRST(&sessionp->mxhosts); if (mxhost == NULL) return -1; @@ -660,6 +662,7 @@ mta_write(int s, short event, void *arg) free(mxhost); } close(s); + sessionp->s_fd = -1; if (sessionp->s_bev) { bufferevent_free(sessionp->s_bev); diff --git a/usr.sbin/smtpd/smtp_session.c b/usr.sbin/smtpd/smtp_session.c index fe8a925932a..d8c37a86232 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.103 2009/05/30 16:22:07 gilles Exp $ */ +/* $OpenBSD: smtp_session.c,v 1.104 2009/05/31 18:34:48 gilles Exp $ */ /* * Copyright (c) 2008 Gilles Chehade <gilles@openbsd.org> @@ -955,7 +955,7 @@ session_destroy(struct session *s) if (s->s_bev != NULL) bufferevent_free(s->s_bev); - if (close(s->s_fd) == -1) + if (s->s_fd != -1 && close(s->s_fd) == -1) fatal("session_destroy: close"); switch (smtpd_process) { |