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
|
void
|
||||||
dictinit(char *dir)
|
dictinit(char *dir)
|
||||||
{
|
{
|
||||||
char path[1024];
|
char *path;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for(i = 0; i < nlang; i++){
|
for(i = 0; i < nlang; i++){
|
||||||
if(langs[i].dictname == nil)
|
if(langs[i].dictname == nil)
|
||||||
continue;
|
continue;
|
||||||
if(snprint(path, sizeof(path), "%s/%s.dict", dir,
|
path = smprint("%s/%s.dict", dir, langs[i].dictname);
|
||||||
langs[i].dictname) >= (int)sizeof path)
|
if(path == nil)
|
||||||
die("dictionary path too long: %s/%s.dict",
|
die("out of memory");
|
||||||
dir, langs[i].dictname);
|
|
||||||
langs[i].dict = dictopen(path);
|
langs[i].dict = dictopen(path);
|
||||||
|
free(path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
8
srv.c
8
srv.c
@@ -74,14 +74,16 @@ clientthread(void *arg)
|
|||||||
static void
|
static void
|
||||||
srvinit(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)
|
if(ipcpath(path, sizeof path) < 0)
|
||||||
die("IPC path is too long");
|
die("IPC path is too long");
|
||||||
if(snprint(addr, sizeof addr, "unix!%s", path) >= (int)sizeof addr)
|
addr = smprint("unix!%s", path);
|
||||||
die("IPC address is too long");
|
if(addr == nil)
|
||||||
|
die("out of memory");
|
||||||
if(announce(addr, adir) < 0)
|
if(announce(addr, adir) < 0)
|
||||||
die("IPC endpoint is already in use: %r");
|
die("IPC endpoint is already in use: %r");
|
||||||
|
free(addr);
|
||||||
if(chmod(path, 0600) < 0)
|
if(chmod(path, 0600) < 0)
|
||||||
die("can't protect IPC endpoint: %s", path);
|
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
|
void
|
||||||
mapinit(char *dir)
|
mapinit(char *dir)
|
||||||
{
|
{
|
||||||
char path[1024];
|
char *path;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for(i = 0; i < nelem(langs); i++){
|
for(i = 0; i < nelem(langs); i++){
|
||||||
if(langs[i].mapname == nil)
|
if(langs[i].mapname == nil)
|
||||||
continue;
|
continue;
|
||||||
if(snprint(path, sizeof(path), "%s/%s.map", dir,
|
path = smprint("%s/%s.map", dir, langs[i].mapname);
|
||||||
langs[i].mapname) >= (int)sizeof path)
|
if(path == nil)
|
||||||
die("map path too long: %s/%s.map", dir, langs[i].mapname);
|
die("out of memory");
|
||||||
langs[i].map = trieopen(path);
|
langs[i].map = trieopen(path);
|
||||||
|
free(path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user