From e3e1bdfb135fe3d74d20b94a8191714dc04fb782 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Tue, 30 Oct 2018 21:03:22 -0400 Subject: ipc-unix: leave room for a NUL terminator The `strncpy` function will not always place a terminating `NUL` if the source is longer than the destination buffer. Instead, let `strncpy` truncate as it normally would, but leave the last byte alone (it is zero-initialized when declared). --- input/ipc-unix.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/input/ipc-unix.c b/input/ipc-unix.c index 778f2f1e46..ff8327b178 100644 --- a/input/ipc-unix.c +++ b/input/ipc-unix.c @@ -324,7 +324,7 @@ static void *ipc_thread(void *p) } ipc_un.sun_family = AF_UNIX, - strncpy(ipc_un.sun_path, arg->path, sizeof(ipc_un.sun_path)); + strncpy(ipc_un.sun_path, arg->path, sizeof(ipc_un.sun_path) - 1); unlink(ipc_un.sun_path); -- cgit v1.2.3