From ce0b82ef25798b9eda5abb1a5bfcdea6f5f7a8a7 Mon Sep 17 00:00:00 2001 From: Johan Wikman Date: Mon, 5 Sep 2016 10:15:55 +0300 Subject: [PATCH] Ensure buffer has enough space In the case of a Unix domain socket, the required buffer size may in principle be up to PATH_MAX, so better to explicitly ensure that there's enough space. --- server/core/service.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/server/core/service.c b/server/core/service.c index 8eade731d..4660f95e4 100644 --- a/server/core/service.c +++ b/server/core/service.c @@ -221,8 +221,12 @@ service_isvalid(SERVICE *service) static int serviceStartPort(SERVICE *service, SERV_LISTENER *port) { + const size_t ANY_IPV4_ADDRESS_LEN = 7; // strlen("0:0:0:0"); + int listeners = 0; - char config_bind[40]; + size_t config_bind_len = + (port->address ? strlen(port->address) : ANY_IPV4_ADDRESS_LEN) + 1 + UINTLEN(port->port); + char config_bind[config_bind_len + 1]; // +1 for NULL GWPROTOCOL *funcs; if (service == NULL || service->router == NULL || service->router_instance == NULL)