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:
Ben Boeckel 2018-10-30 21:03:22 -04:00 committed by sfan5
parent 84d6638907
commit e3e1bdfb13
1 changed files with 1 additions and 1 deletions

View File

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