diff --git a/NEWS b/NEWS index 73470128..bf8984f5 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 ebde43bc..776a86ce 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))) {