diff options
author | Charles Longeau <chl@cvs.openbsd.org> | 2012-10-02 12:37:39 +0000 |
---|---|---|
committer | Charles Longeau <chl@cvs.openbsd.org> | 2012-10-02 12:37:39 +0000 |
commit | 81b0ab8e5a54cf0e38b8ed756c64975e13871452 (patch) | |
tree | 70663c122268342fa6afbc7f2eac9127f50aad3a | |
parent | f52927cb1ba328594c8f4b934c14bca4916ef8e5 (diff) |
check iobuf_init() return value.
ok gilles@ eric@
-rw-r--r-- | usr.sbin/smtpd/bounce.c | 9 | ||||
-rw-r--r-- | usr.sbin/smtpd/mta_session.c | 9 | ||||
-rw-r--r-- | usr.sbin/smtpd/smtp.c | 17 |
3 files changed, 25 insertions, 10 deletions
diff --git a/usr.sbin/smtpd/bounce.c b/usr.sbin/smtpd/bounce.c index cf223196d89..af0d6432da4 100644 --- a/usr.sbin/smtpd/bounce.c +++ b/usr.sbin/smtpd/bounce.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bounce.c,v 1.48 2012/09/26 21:06:45 chl Exp $ */ +/* $OpenBSD: bounce.c,v 1.49 2012/10/02 12:37:38 chl Exp $ */ /* * Copyright (c) 2009 Gilles Chehade <gilles@openbsd.org> @@ -166,7 +166,12 @@ bounce_run(uint64_t id, int fd) } bounce->state = BOUNCE_EHLO; - iobuf_init(&bounce->iobuf, 0, 0); + if (iobuf_init(&bounce->iobuf, 0, 0) == -1) { + bounce_status(bounce, "iobuf_init"); + bounce_free(bounce); + close(msgfd); + return; + } io_init(&bounce->io, fd, bounce, bounce_io, &bounce->iobuf); io_set_timeout(&bounce->io, 30000); io_set_read(&bounce->io); diff --git a/usr.sbin/smtpd/mta_session.c b/usr.sbin/smtpd/mta_session.c index 085aa76c1ab..e3cc2158e04 100644 --- a/usr.sbin/smtpd/mta_session.c +++ b/usr.sbin/smtpd/mta_session.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mta_session.c,v 1.19 2012/09/30 17:25:09 chl Exp $ */ +/* $OpenBSD: mta_session.c,v 1.20 2012/10/02 12:37:38 chl Exp $ */ /* * Copyright (c) 2008 Pierre-Yves Ritschard <pyr@openbsd.org> @@ -357,7 +357,12 @@ mta_enter_state(struct mta_session *s, int newstate) else sa_set_port(sa, 25); - iobuf_init(&s->iobuf, 0, 0); + if (iobuf_init(&s->iobuf, 0, 0) == -1) { + log_debug("mta: %p: iobuf_init()", s); + TAILQ_REMOVE(&s->hosts, host, entry); + free(host); + continue; + } io_init(&s->io, -1, s, mta_io, &s->iobuf); io_set_timeout(&s->io, 10000); if (io_connect(&s->io, sa) == -1) { diff --git a/usr.sbin/smtpd/smtp.c b/usr.sbin/smtpd/smtp.c index 6b9d75c5100..c1e1cf3c3cd 100644 --- a/usr.sbin/smtpd/smtp.c +++ b/usr.sbin/smtpd/smtp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: smtp.c,v 1.117 2012/09/29 22:16:46 chl Exp $ */ +/* $OpenBSD: smtp.c,v 1.118 2012/10/02 12:37:38 chl Exp $ */ /* * Copyright (c) 2008 Gilles Chehade <gilles@openbsd.org> @@ -502,12 +502,21 @@ smtp_new(struct listener *l) if (! smtp_can_accept()) return (NULL); - sessions++; s = xcalloc(1, sizeof(*s), "smtp_new"); s->s_id = generate_uid(); s->s_l = l; strlcpy(s->s_msg.tag, l->tag, sizeof(s->s_msg.tag)); + + if (iobuf_init(&s->s_iobuf, MAX_LINE_SIZE, MAX_LINE_SIZE) == -1) { + free(s); + return (NULL); + } + io_init(&s->s_io, -1, s, session_io, &s->s_iobuf); + s->s_state = S_CONNECTED; + + sessions++; + SPLAY_INSERT(sessiontree, &env->sc_sessions, s); stat_increment("smtp.session", 1); @@ -519,10 +528,6 @@ smtp_new(struct listener *l) if (s->s_l->ss.ss_family == AF_INET6) stat_increment("smtp.session.inet6", 1); - iobuf_init(&s->s_iobuf, MAX_LINE_SIZE, MAX_LINE_SIZE); - io_init(&s->s_io, -1, s, session_io, &s->s_iobuf); - s->s_state = S_CONNECTED; - return (s); } |