projects
/
musl
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
add prototype for BSD/GNU stdio *_unlocked extension functions
[musl]
/
src
/
passwd
/
getpw_r.c
diff --git
a/src/passwd/getpw_r.c
b/src/passwd/getpw_r.c
index
7b331e8
..
3974495
100644
(file)
--- a/
src/passwd/getpw_r.c
+++ b/
src/passwd/getpw_r.c
@@
-1,4
+1,5
@@
#include "pwf.h"
#include "pwf.h"
+#include <pthread.h>
#define FIX(x) (pw->pw_##x = pw->pw_##x-line+buf)
#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;
char *line = 0;
size_t len = 0;
int rv = 0;
+ int cs;
+
+ pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &cs);
f = fopen("/etc/passwd", "rb");
f = fopen("/etc/passwd", "rb");
- if (!f) return errno;
+ if (!f) {
+ rv = errno;
+ goto done;
+ }
*res = 0;
while (__getpwent_a(f, pw, &line, &len)) {
*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);
}
free(line);
fclose(f);
+done:
+ pthread_setcancelstate(cs, 0);
return rv;
}
return rv;
}