From a831490462e88f837c6e70cfab8f651868a8571c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Wed, 6 Feb 2019 18:10:06 +0100 Subject: [PATCH] modules: fix strncpy calls to ensure strings are NULL-terminated --- modules/i3.c | 2 +- modules/mpd.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/i3.c b/modules/i3.c index 433fcf7..81e2ec8 100644 --- a/modules/i3.c +++ b/modules/i3.c @@ -442,7 +442,7 @@ get_socket_address(struct sockaddr_un *addr) #endif } - strncpy(addr->sun_path, sway_sock, sizeof(addr->sun_path)); + strncpy(addr->sun_path, sway_sock, sizeof(addr->sun_path) - 1); return true; } diff --git a/modules/mpd.c b/modules/mpd.c index 6606df3..ac74854 100644 --- a/modules/mpd.c +++ b/modules/mpd.c @@ -216,7 +216,7 @@ wait_for_socket_create(const struct module *mod) int s = socket(AF_UNIX, SOCK_STREAM, 0); struct sockaddr_un addr = {.sun_family = AF_UNIX}; - strncpy(addr.sun_path, m->host, sizeof(addr.sun_path)); + strncpy(addr.sun_path, m->host, sizeof(addr.sun_path) - 1); int r = connect(s, (const struct sockaddr *)&addr, sizeof(addr));