From b0a632f253737463138c182a3fb9c8be04caef5d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20B=C3=BChler?= Date: Sat, 7 Feb 2015 11:33:30 +0000 Subject: [PATCH 12/29] [network] fix compile break in calculation of sockaddr_un size if SUN_LEN is not defined (fixes #2609) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Stefan Bühler git-svn-id: svn://svn.lighttpd.net/lighttpd/branches/lighttpd-1.4.x@2972 152afb58-edef-0310-8abb-c4023f1b3aa9 --- NEWS | 1 + src/network.c | 13 +++++++------ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/NEWS b/NEWS index 7347012..bf8984f 100644 --- a/NEWS +++ b/NEWS @@ -12,6 +12,7 @@ NEWS * [mod_dirlisting,mod_redirect,mod_rewrite] abort config parsing if pcre-compile fails or isn't available * [ssl] disable SSL3.0 by default * fixed typo in example config found by openSUSE user (boo# 907709) + * [network] fix compile break in calculation of sockaddr_un size if SUN_LEN is not defined (fixes #2609) - 1.4.35 - 2014-03-12 * [network/ssl] fix build error if TLSEXT is disabled diff --git a/src/network.c b/src/network.c index ebde43b..776a86c 100644 --- a/src/network.c +++ b/src/network.c @@ -349,6 +349,8 @@ static int network_server_init(server *srv, buffer *host_token, specific_config break; case AF_UNIX: + memset(&srv_socket->addr, 0, sizeof(struct sockaddr_un)); + srv_socket->addr.un.sun_family = AF_UNIX; { size_t hostlen = strlen(host) + 1; if (hostlen > sizeof(srv_socket->addr.un.sun_path)) { @@ -356,15 +358,14 @@ static int network_server_init(server *srv, buffer *host_token, specific_config goto error_free_socket; } memcpy(srv_socket->addr.un.sun_path, host, hostlen); - } - srv_socket->addr.un.sun_family = AF_UNIX; -#ifdef SUN_LEN - addr_len = SUN_LEN(&srv_socket->addr.un); +#if defined(SUN_LEN) + addr_len = SUN_LEN(&srv_socket->addr.un); #else - /* stevens says: */ - addr_len = hostlen + sizeof(srv_socket->addr.un.sun_family); + /* stevens says: */ + addr_len = hostlen + sizeof(srv_socket->addr.un.sun_family); #endif + } /* check if the socket exists and try to connect to it. */ if (-1 != (fd = connect(srv_socket->fd, (struct sockaddr *) &(srv_socket->addr), addr_len))) { -- 2.4.5