From cf51503a54ea9794d239c66c843914ae60bad46e Mon Sep 17 00:00:00 2001 From: Geoffrey McRae Date: Sat, 11 Nov 2023 13:47:43 +1100 Subject: [PATCH] [client] X11/i3: write directly into sun_path to avoid strncpy --- client/displayservers/X11/wm/i3.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/client/displayservers/X11/wm/i3.c b/client/displayservers/X11/wm/i3.c index a2e9d419..d30fb29a 100644 --- a/client/displayservers/X11/wm/i3.c +++ b/client/displayservers/X11/wm/i3.c @@ -71,9 +71,9 @@ static bool wm_i3_init(void) return false; struct sockaddr_un addr = { .sun_family = AF_UNIX }; - char path[sizeof(addr.sun_path)]; + char * path = (char *)&addr.sun_path; int pathLen; - if ((pathLen = fread(path, 1, sizeof(path), fd)) <= 0) + if ((pathLen = fread(path, 1, sizeof(addr.sun_path), fd)) <= 0) { pclose(fd); return false; @@ -91,7 +91,6 @@ static bool wm_i3_init(void) return false; } - strncpy(addr.sun_path, path, sizeof(addr.sun_path)); if (connect(i3.sock, (struct sockaddr *)&addr, sizeof(addr)) < 0) { DEBUG_ERROR("Failed to connect to the i3 IPC socket");