fix: construct Plan 9 paths without truncation
This commit is contained in:
10
dict.c
10
dict.c
@@ -99,16 +99,16 @@ dictopen(char *path)
|
||||
void
|
||||
dictinit(char *dir)
|
||||
{
|
||||
char path[1024];
|
||||
char *path;
|
||||
int i;
|
||||
|
||||
for(i = 0; i < nlang; i++){
|
||||
if(langs[i].dictname == nil)
|
||||
continue;
|
||||
if(snprint(path, sizeof(path), "%s/%s.dict", dir,
|
||||
langs[i].dictname) >= (int)sizeof path)
|
||||
die("dictionary path too long: %s/%s.dict",
|
||||
dir, langs[i].dictname);
|
||||
path = smprint("%s/%s.dict", dir, langs[i].dictname);
|
||||
if(path == nil)
|
||||
die("out of memory");
|
||||
langs[i].dict = dictopen(path);
|
||||
free(path);
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
9
strans.c
9
strans.c
@@ -860,15 +860,16 @@ mapget(Trie *t, Str *key, Str *out)
|
||||
void
|
||||
mapinit(char *dir)
|
||||
{
|
||||
char path[1024];
|
||||
char *path;
|
||||
int i;
|
||||
|
||||
for(i = 0; i < nelem(langs); i++){
|
||||
if(langs[i].mapname == nil)
|
||||
continue;
|
||||
if(snprint(path, sizeof(path), "%s/%s.map", dir,
|
||||
langs[i].mapname) >= (int)sizeof path)
|
||||
die("map path too long: %s/%s.map", dir, langs[i].mapname);
|
||||
path = smprint("%s/%s.map", dir, langs[i].mapname);
|
||||
if(path == nil)
|
||||
die("out of memory");
|
||||
langs[i].map = trieopen(path);
|
||||
free(path);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user