summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGlenn Strauss <gstrauss@gluelogic.com>2017-10-22 12:24:18 -0400
committerGlenn Strauss <gstrauss@gluelogic.com>2017-10-22 12:41:02 -0400
commit585206616d867c3bd3171331bf63cdadd8e5093d (patch)
tree1691e1145ba317b4891126f36fe7d7690cff6709
parent60b5826849710f8f7bd8dbb8a31f94aef9ae6254 (diff)
downloadlighttpd1.4-585206616d867c3bd3171331bf63cdadd8e5093d.tar.gz
lighttpd1.4-585206616d867c3bd3171331bf63cdadd8e5093d.zip
[core] fix 1.4.46 regression in config match (fixes #2830)
address strings need to have DNS resolved and port added for consistency when matching other config conditionals x-ref: "1.4.46 regression: $SERVER["socket"] matches when it shouldn't" https://redmine.lighttpd.net/issues/2830
-rw-r--r--src/network.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/network.c b/src/network.c
index 566b2567..d284da50 100644
--- a/src/network.c
+++ b/src/network.c
@@ -205,7 +205,14 @@ static int network_server_init(server *srv, buffer *host_token, size_t sidx, int
srv_socket->is_ssl = s->ssl_enabled;
srv_socket->srv_token = buffer_init();
- sock_addr_inet_ntop_copy_buffer(srv_socket->srv_token, &srv_socket->addr);
+ if (addr.plain.sa_family == AF_INET6) buffer_append_string_len(srv_socket->srv_token, CONST_STR_LEN("["));
+ sock_addr_inet_ntop_append_buffer(srv_socket->srv_token, &srv_socket->addr);
+ if (addr.plain.sa_family == AF_INET6) buffer_append_string_len(srv_socket->srv_token, CONST_STR_LEN("]"));
+ if (addr.plain.sa_family != AF_UNIX) {
+ port = addr.plain.sa_family == AF_INET ? ntohs(addr.ipv4.sin_port) : ntohs(addr.ipv6.sin6_port);
+ buffer_append_string_len(srv_socket->srv_token, CONST_STR_LEN(":"));
+ buffer_append_int(srv_socket->srv_token, (int)port);
+ }
/* update host_token (dc->string) for consistent string comparison in lighttpd.conf conditions */
buffer_copy_buffer(host_token, srv_socket->srv_token);