Skip to content
Permalink
Browse files

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
  • Loading branch information
fobser committed Apr 23, 2015
1 parent 423631c commit 49b1a9b154081c713af219b2422adaf51ca2584d
Showing with 6 additions and 8 deletions.
  1. +6 −8 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,

0 comments on commit 49b1a9b

Please sign in to comment.
You can’t perform that action at this time.