Fix gcc string truncation warnings

This commit is contained in:
Dominique Martinet 2018-04-13 22:35:23 +09:00
parent 54ae394754
commit 25af959fe9
4 changed files with 4 additions and 4 deletions

View file

@ -48,7 +48,7 @@ int ipc_open_socket(const char *socket_path) {
sway_abort("Unable to open Unix socket");
}
addr.sun_family = AF_UNIX;
strncpy(addr.sun_path, socket_path, sizeof(addr.sun_path));
strncpy(addr.sun_path, socket_path, sizeof(addr.sun_path) - 1);
addr.sun_path[sizeof(addr.sun_path) - 1] = 0;
int l = sizeof(struct sockaddr_un);
if (connect(socketfd, (struct sockaddr *)&addr, l) == -1) {