diff options
author | cinap_lenrek <cinap_lenrek@gmx.de> | 2012-12-03 18:47:41 +0100 |
---|---|---|
committer | cinap_lenrek <cinap_lenrek@gmx.de> | 2012-12-03 18:47:41 +0100 |
commit | 4661934e31d3eee9414eb44ffc5a7e355326bc31 (patch) | |
tree | a9b4bbcb3a85a89d1a5f8311c4d7e3afcaa776d2 /sys/src/ape/lib/ap/plan9/_getpw.c | |
parent | 52b9a0689603622fe9f2b7610e428c125e4acbb7 (diff) |
ape: fix _grpmems(), access(), getppid(), cleanup
_grpmems() was broken tokenizing group list in place.
we have to copy it to status buffer before tokenizing.
dynamically alloc path for test file to check write
permission on directory and add pid to the name to
prevent races.
use _OPEN instead of ape open to read /dev/ppid in
getppid().
use mode enums instead of numeric constants for _OPEN()
and _CREATE().
Diffstat (limited to 'sys/src/ape/lib/ap/plan9/_getpw.c')
-rw-r--r-- | sys/src/ape/lib/ap/plan9/_getpw.c | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/sys/src/ape/lib/ap/plan9/_getpw.c b/sys/src/ape/lib/ap/plan9/_getpw.c index 151d7f3c8..2c6a740a7 100644 --- a/sys/src/ape/lib/ap/plan9/_getpw.c +++ b/sys/src/ape/lib/ap/plan9/_getpw.c @@ -153,20 +153,19 @@ _grpmems(char *list) char **v; char *p; static char *holdvec[200]; - static char holdlist[1000]; + static char holdlist[1024]; - p = list; v = holdvec; - if(p) { - strncpy(holdlist, list, sizeof(holdlist)); + if(list != 0){ + memset(holdlist, 0, sizeof(holdlist)); + strncpy(holdlist, list, sizeof(holdlist)-1); + p = holdlist; while(v< &holdvec[sizeof(holdvec)]-1 && *p){ *v++ = p; p = strchr(p, ','); - if(p){ - p++; - *p = 0; - }else + if(p == 0) break; + *p++ = 0; } } *v = 0; |