summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBen Boeckel <mathstuf@gmail.com>2018-10-30 21:03:22 -0400
committersfan5 <sfan5@live.de>2018-10-31 09:20:26 +0100
commite3e1bdfb135fe3d74d20b94a8191714dc04fb782 (patch)
tree4418b4ec328ad0b5da5fd140a39a0d2d9e1a458c
parent84d6638907b488a1724ec33978773ef8a586dfc0 (diff)
downloadmpv-e3e1bdfb135fe3d74d20b94a8191714dc04fb782.tar.bz2
mpv-e3e1bdfb135fe3d74d20b94a8191714dc04fb782.tar.xz
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).
-rw-r--r--input/ipc-unix.c2
1 files changed, 1 insertions, 1 deletions
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);