fix: construct Plan 9 paths without truncation
This commit is contained in:
8
srv.c
8
srv.c
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user