[client] X11/i3: write directly into sun_path to avoid strncpy

This commit is contained in:
Geoffrey McRae 2023-11-11 13:47:43 +11:00
parent aa42751743
commit cf51503a54

View File

@ -71,9 +71,9 @@ static bool wm_i3_init(void)
return false; return false;
struct sockaddr_un addr = { .sun_family = AF_UNIX }; struct sockaddr_un addr = { .sun_family = AF_UNIX };
char path[sizeof(addr.sun_path)]; char * path = (char *)&addr.sun_path;
int pathLen; int pathLen;
if ((pathLen = fread(path, 1, sizeof(path), fd)) <= 0) if ((pathLen = fread(path, 1, sizeof(addr.sun_path), fd)) <= 0)
{ {
pclose(fd); pclose(fd);
return false; return false;
@ -91,7 +91,6 @@ static bool wm_i3_init(void)
return false; return false;
} }
strncpy(addr.sun_path, path, sizeof(addr.sun_path));
if (connect(i3.sock, (struct sockaddr *)&addr, sizeof(addr)) < 0) if (connect(i3.sock, (struct sockaddr *)&addr, sizeof(addr)) < 0)
{ {
DEBUG_ERROR("Failed to connect to the i3 IPC socket"); DEBUG_ERROR("Failed to connect to the i3 IPC socket");