summaryrefslogtreecommitdiff
path: root/src/network.c
diff options
context:
space:
mode:
authorStefan Bühler <stbuehler@web.de>2016-03-19 13:06:56 +0000
committerStefan Bühler <stbuehler@web.de>2016-03-19 13:06:56 +0000
commit70036ff572f414f6276a5420280faa3cf645d9a3 (patch)
tree5620193f1f39024b3708dc84344b82a9dfe37f94 /src/network.c
parentd85bdab43ff115763deb6f5cb292f650397fe5f4 (diff)
downloadlighttpd1.4-70036ff572f414f6276a5420280faa3cf645d9a3.tar.gz
lighttpd1.4-70036ff572f414f6276a5420280faa3cf645d9a3.zip
[core] accept $SERVER["socket"] without port, use server.port as fallback (fixes #2204)
From: Stefan Bühler <stbuehler@web.de> git-svn-id: svn://svn.lighttpd.net/lighttpd/branches/lighttpd-1.4.x@3105 152afb58-edef-0310-8abb-c4023f1b3aa9
Diffstat (limited to 'src/network.c')
-rw-r--r--src/network.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/network.c b/src/network.c
index 53aadb31..017d77dd 100644
--- a/src/network.c
+++ b/src/network.c
@@ -204,9 +204,14 @@ static int network_server_init(server *srv, buffer *host_token, specific_config
*/
size_t len = buffer_string_length(b);
char *sp = NULL;
- if ((b->ptr[0] == '[' && b->ptr[len-1] == ']') || NULL == (sp = strrchr(b->ptr, ':'))) {
- log_error_write(srv, __FILE__, __LINE__, "sb", "value of $SERVER[\"socket\"] has to be \"ip:port\".", b);
+ if (0 == len) {
+ log_error_write(srv, __FILE__, __LINE__, "s", "value of $SERVER[\"socket\"] must not be empty");
goto error_free_socket;
+ }
+ if ((b->ptr[0] == '[' && b->ptr[len-1] == ']') || NULL == (sp = strrchr(b->ptr, ':'))) {
+ /* use server.port if set in config, or else default from config_set_defaults() */
+ port = srv->srvconf.port;
+ sp = b->ptr + len; /* point to '\0' at end of string so end of IPv6 address can be found below */
} else {
/* found ip:port separator at *sp; port doesn't end in ']', so *sp hopefully doesn't split an IPv6 address */
*(sp++) = '\0';
@@ -222,7 +227,7 @@ static int network_server_init(server *srv, buffer *host_token, specific_config
}
if (port == 0 || port > 65535) {
- log_error_write(srv, __FILE__, __LINE__, "sd", "port out of range:", port);
+ log_error_write(srv, __FILE__, __LINE__, "sd", "port not set or out of range:", port);
goto error_free_socket;
}