X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=src%2Fpasswd%2Fgetgr_r.c;h=234c90131143fd98fa3fef7c5954d7da8855144f;hb=a764db9a086ca036d4fc9181f96d19ab312a6560;hp=5b1333e3b14f9c347dc36d1985d1c32c7c71bc6e;hpb=0b44a0315b47dd8eced9f3b7f31580cf14bbfc01;p=musl diff --git a/src/passwd/getgr_r.c b/src/passwd/getgr_r.c index 5b1333e3..234c9013 100644 --- a/src/passwd/getgr_r.c +++ b/src/passwd/getgr_r.c @@ -1,4 +1,5 @@ #include "pwf.h" +#include #define FIX(x) (gr->gr_##x = gr->gr_##x-line+buf) @@ -11,9 +12,15 @@ static int getgr_r(const char *name, gid_t gid, struct group *gr, char *buf, siz size_t nmem = 0; int rv = 0; size_t i; + int cs; - f = fopen("/etc/group", "rb"); - if (!f) return errno; + pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &cs); + + f = fopen("/etc/group", "rbe"); + if (!f) { + rv = errno; + goto done; + } *res = 0; while (__getgrent_a(f, gr, &line, &len, &mem, &nmem)) { @@ -39,6 +46,8 @@ static int getgr_r(const char *name, gid_t gid, struct group *gr, char *buf, siz free(mem); free(line); fclose(f); +done: + pthread_setcancelstate(cs, 0); return rv; } @@ -47,7 +56,7 @@ int getgrnam_r(const char *name, struct group *gr, char *buf, size_t size, struc return getgr_r(name, 0, gr, buf, size, res); } -int getgruid_r(gid_t gid, struct group *gr, char *buf, size_t size, struct group **res) +int getgrgid_r(gid_t gid, struct group *gr, char *buf, size_t size, struct group **res) { return getgr_r(0, gid, gr, buf, size, res); }