X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=src%2Fpasswd%2Fgetpw_r.c;h=285525727dc74647e56726f2f894956d00776fa0;hb=2d0f495e7bbcc1b17bf118b939e347e2d771fa2f;hp=7b331e8a39109bda2017ccea7ac44a702cb246cc;hpb=0b44a0315b47dd8eced9f3b7f31580cf14bbfc01;p=musl diff --git a/src/passwd/getpw_r.c b/src/passwd/getpw_r.c index 7b331e8a..28552572 100644 --- a/src/passwd/getpw_r.c +++ b/src/passwd/getpw_r.c @@ -1,4 +1,5 @@ #include "pwf.h" +#include #define FIX(x) (pw->pw_##x = pw->pw_##x-line+buf) @@ -8,9 +9,15 @@ static int getpw_r(const char *name, uid_t uid, struct passwd *pw, char *buf, si char *line = 0; size_t len = 0; int rv = 0; + int cs; - f = fopen("/etc/passwd", "rb"); - if (!f) return errno; + pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &cs); + + f = fopen("/etc/passwd", "rbe"); + if (!f) { + rv = errno; + goto done; + } *res = 0; while (__getpwent_a(f, pw, &line, &len)) { @@ -32,6 +39,8 @@ static int getpw_r(const char *name, uid_t uid, struct passwd *pw, char *buf, si } free(line); fclose(f); +done: + pthread_setcancelstate(cs, 0); return rv; }