summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGilles Chehade <gilles@cvs.openbsd.org>2009-03-19 00:12:33 +0000
committerGilles Chehade <gilles@cvs.openbsd.org>2009-03-19 00:12:33 +0000
commitb493c6dbb14f41e9edde9f49f4568aeefb1e85c0 (patch)
treed51357e304c5ed419533caae544c7e3c62b15b71
parent20127615175df15be96c7c67262e20302222964d (diff)
in the event of a timeout, mxhost is passed to TAILQ_REMOVE before it is
initialized. spotted and diff by Matthew Haub <matthew.haub@alumni.adelaide.edu.au>
-rw-r--r--usr.sbin/smtpd/mta.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/usr.sbin/smtpd/mta.c b/usr.sbin/smtpd/mta.c
index f499bd082d0..56dbf706dbb 100644
--- a/usr.sbin/smtpd/mta.c
+++ b/usr.sbin/smtpd/mta.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mta.c,v 1.37 2009/03/18 23:51:34 gilles Exp $ */
+/* $OpenBSD: mta.c,v 1.38 2009/03/19 00:12:32 gilles Exp $ */
/*
* Copyright (c) 2008 Pierre-Yves Ritschard <pyr@openbsd.org>
@@ -586,10 +586,14 @@ mta_write(int s, short event, void *arg)
struct mxhost *mxhost;
int ret;
+ mxhost = TAILQ_FIRST(&sessionp->mxhosts);
+
if (event == EV_TIMEOUT) {
- TAILQ_REMOVE(&sessionp->mxhosts, mxhost, entry);
- free(mxhost);
+ if (mxhost) {
+ TAILQ_REMOVE(&sessionp->mxhosts, mxhost, entry);
+ free(mxhost);
+ }
close(s);
if (sessionp->s_bev) {
@@ -620,8 +624,7 @@ mta_write(int s, short event, void *arg)
return;
}
- mxhost = TAILQ_FIRST(&sessionp->mxhosts);
- if (mxhost->flags & F_SSMTP) {
+ if (mxhost && mxhost->flags & F_SSMTP) {
ssl_client_init(sessionp);
return;
}