mirror of
https://github.com/mpv-player/mpv
synced 2025-03-11 08:37:59 +00:00
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).
This commit is contained in:
parent
84d6638907
commit
e3e1bdfb13
@ -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);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user