From: Dennis Chen Date: Thu, 2 Jan 2020 13:30:58 +0000 (-0600) Subject: bugfix: off by one error (#257) X-Git-Url: http://git.prime8.dev/?a=commitdiff_plain;h=498874deb851b913acbc102fcc85b2fe95ed9e72;p=ttyd.git bugfix: off by one error (#257) The strncpy function requires enough space for a NUL terminator. --- diff --git a/src/server.c b/src/server.c index 7453044..d586c8a 100644 --- a/src/server.c +++ b/src/server.c @@ -431,7 +431,7 @@ main(int argc, char **argv) { if (endswith(info.iface, ".sock") || endswith(info.iface, ".socket")) { #if defined(LWS_USE_UNIX_SOCK) || defined(LWS_WITH_UNIX_SOCK) info.options |= LWS_SERVER_OPTION_UNIX_SOCK; - strncpy(server->socket_path, info.iface, sizeof(server->socket_path)); + strncpy(server->socket_path, info.iface, sizeof(server->socket_path) - 1); #else fprintf(stderr, "libwebsockets is not compiled with UNIX domain socket support"); return -1;