diff options
author | Ben Boeckel <mathstuf@gmail.com> | 2018-10-30 21:03:22 -0400 |
---|---|---|
committer | sfan5 <sfan5@live.de> | 2018-10-31 09:20:26 +0100 |
commit | e3e1bdfb135fe3d74d20b94a8191714dc04fb782 (patch) | |
tree | 4418b4ec328ad0b5da5fd140a39a0d2d9e1a458c /input | |
parent | 84d6638907b488a1724ec33978773ef8a586dfc0 (diff) | |
download | mpv-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).
Diffstat (limited to 'input')
-rw-r--r-- | input/ipc-unix.c | 2 |
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); |