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.
This commit is contained in:
Johan Wikman
2016-09-05 10:15:55 +03:00
parent 1e59e04002
commit ce0b82ef25

View File

@ -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)