bugfix: off by one error (#257)

The strncpy function requires enough space for a NUL terminator.
This commit is contained in:
Dennis Chen
2020-01-02 07:30:58 -06:00
committed by Shuanglei Tao
parent aed3faa38d
commit 498874deb8

View File

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