fix: construct Plan 9 paths without truncation

This commit is contained in:
2026-08-12 17:28:17 +09:00
parent 0d06ba43cd
commit a8a6c3b455
3 changed files with 15 additions and 12 deletions

8
srv.c
View File

@@ -74,14 +74,16 @@ clientthread(void *arg)
static void
srvinit(void)
{
char addr[128], path[sizeof(((struct sockaddr_un*)0)->sun_path)];
char *addr, path[sizeof(((struct sockaddr_un*)0)->sun_path)];
if(ipcpath(path, sizeof path) < 0)
die("IPC path is too long");
if(snprint(addr, sizeof addr, "unix!%s", path) >= (int)sizeof addr)
die("IPC address is too long");
addr = smprint("unix!%s", path);
if(addr == nil)
die("out of memory");
if(announce(addr, adir) < 0)
die("IPC endpoint is already in use: %r");
free(addr);
if(chmod(path, 0600) < 0)
die("can't protect IPC endpoint: %s", path);
}