From: florian Date: Thu, 23 Apr 2015 16:59:28 +0000 (+0000) Subject: We cannot log errors with server_close() before allocating X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=49b1a9b154081c713af219b2422adaf51ca2584d;p=openbsd 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 , thanks! OK benno --- 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 @@ -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,