diff options
author | 2015-04-23 16:59:28 +0000 | |
---|---|---|
committer | 2015-04-23 16:59:28 +0000 | |
commit | 49b1a9b154081c713af219b2422adaf51ca2584d (patch) | |
tree | 806cec8339171f5d161e378c9860a72d9b7760c2 | |
parent | Unify mdoc_deroff() and man_deroff() into a common function deroff(). (diff) | |
download | wireguard-openbsd-49b1a9b154081c713af219b2422adaf51ca2584d.tar.xz wireguard-openbsd-49b1a9b154081c713af219b2422adaf51ca2584d.zip |
We cannot log errors with server_close() before allocating
clt_log evbuffer.
server_close() calls server_log() which uses ctl_log.
Crash reported by Daniel Jakots <vigdis AT chown DOT me>, thanks!
OK benno
-rw-r--r-- | usr.sbin/httpd/server.c | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/usr.sbin/httpd/server.c b/usr.sbin/httpd/server.c index fe47cf431e9..ca67a470174 100644 --- a/usr.sbin/httpd/server.c +++ b/usr.sbin/httpd/server.c @@ -1,4 +1,4 @@ -/* $OpenBSD: server.c,v 1.62 2015/04/11 14:52:49 jsing Exp $ */ +/* $OpenBSD: server.c,v 1.63 2015/04/23 16:59:28 florian Exp $ */ /* * Copyright (c) 2006 - 2015 Reyk Floeter <reyk@openbsd.org> @@ -852,6 +852,11 @@ server_accept(int fd, short event, void *arg) if ((clt = calloc(1, sizeof(*clt))) == NULL) goto err; + /* Pre-allocate log buffer */ + clt->clt_log = evbuffer_new(); + if (clt->clt_log == NULL) + goto err; + clt->clt_s = s; clt->clt_fd = -1; clt->clt_toread = TOREAD_UNLIMITED; @@ -899,13 +904,6 @@ server_accept(int fd, short event, void *arg) return; } - /* Pre-allocate log buffer */ - clt->clt_log = evbuffer_new(); - if (clt->clt_log == NULL) { - server_close(clt, "failed to allocate log buffer"); - return; - } - if (srv->srv_conf.flags & SRVFLAG_TLS) { event_again(&clt->clt_ev, clt->clt_s, EV_TIMEOUT|EV_READ, server_accept_tls, &clt->clt_tv_start, |