We cannot log errors with relay_close() before allocating
authorflorian <florian@openbsd.org>
Thu, 23 Apr 2015 17:03:01 +0000 (17:03 +0000)
committerflorian <florian@openbsd.org>
Thu, 23 Apr 2015 17:03:01 +0000 (17:03 +0000)
se_log evbuffer.
(Same problem as the one just fixed in httpd(8))
OK benno

usr.sbin/relayd/relay.c

index 0818a69..1fef01f 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: relay.c,v 1.191 2015/02/06 01:37:11 reyk Exp $        */
+/*     $OpenBSD: relay.c,v 1.192 2015/04/23 17:03:01 florian Exp $     */
 
 /*
  * Copyright (c) 2006 - 2014 Reyk Floeter <reyk@openbsd.org>
@@ -1041,6 +1041,12 @@ relay_accept(int fd, short event, void *arg)
        if ((con = calloc(1, sizeof(*con))) == NULL)
                goto err;
 
+       /* Pre-allocate log buffer */
+       con->se_haslog = 0;
+       con->se_log = evbuffer_new();
+       if (con->se_log == NULL)
+               goto err;
+
        con->se_in.s = s;
        con->se_in.ssl = NULL;
        con->se_out.s = -1;
@@ -1094,14 +1100,6 @@ relay_accept(int fd, short event, void *arg)
                return;
        }
 
-       /* Pre-allocate log buffer */
-       con->se_haslog = 0;
-       con->se_log = evbuffer_new();
-       if (con->se_log == NULL) {
-               relay_close(con, "failed to allocate log buffer");
-               return;
-       }
-
        if (rlay->rl_conf.flags & F_DIVERT) {
                slen = sizeof(con->se_out.ss);
                if (getsockname(s, (struct sockaddr *)&con->se_out.ss,