aboutsummaryrefslogtreecommitdiffstats
path: root/main/lighttpd/0012-network-fix-compile-break-in-calculation-of-sockaddr.patch
blob: 9aa38e537da04c78e968df157053fdc74c5e39a7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
From b0a632f253737463138c182a3fb9c8be04caef5d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Stefan=20B=C3=BChler?= <stbuehler@web.de>
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 <stbuehler@web.de>

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