projects
/
musl
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
change uid_t, gid_t, and id_t to unsigned types
[musl]
/
src
/
passwd
/
getpwent_a.c
diff --git
a/src/passwd/getpwent_a.c
b/src/passwd/getpwent_a.c
index
aaf84ed
..
34842a0
100644
(file)
--- a/
src/passwd/getpwent_a.c
+++ b/
src/passwd/getpwent_a.c
@@
-1,14
+1,25
@@
#include "pwf.h"
#include "pwf.h"
+#include <pthread.h>
+
+static unsigned atou(char **s)
+{
+ unsigned x;
+ for (x=0; **s-'0'<10U; ++*s) x=10*x+(**s-'0');
+ return x;
+}
struct passwd *__getpwent_a(FILE *f, struct passwd *pw, char **line, size_t *size)
{
ssize_t l;
char *s;
struct passwd *__getpwent_a(FILE *f, struct passwd *pw, char **line, size_t *size)
{
ssize_t l;
char *s;
+ int cs;
+ pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &cs);
for (;;) {
if ((l=getline(line, size, f)) < 0) {
free(*line);
*line = 0;
for (;;) {
if ((l=getline(line, size, f)) < 0) {
free(*line);
*line = 0;
- return 0;
+ pw = 0;
+ break;
}
line[0][l-1] = 0;
}
line[0][l-1] = 0;
@@
-19,11
+30,11
@@
struct passwd *__getpwent_a(FILE *f, struct passwd *pw, char **line, size_t *siz
*s++ = 0; pw->pw_passwd = s;
if (!(s = strchr(s, ':'))) continue;
*s++ = 0; pw->pw_passwd = s;
if (!(s = strchr(s, ':'))) continue;
- *s++ = 0; pw->pw_uid = ato
i(
s);
- if (
!(s = strchr(s, ':'))
) continue;
+ *s++ = 0; pw->pw_uid = ato
u(&
s);
+ if (
*s != ':'
) continue;
- *s++ = 0; pw->pw_gid = ato
i(
s);
- if (
!(s = strchr(s, ':'))
) continue;
+ *s++ = 0; pw->pw_gid = ato
u(&
s);
+ if (
*s != ':'
) continue;
*s++ = 0; pw->pw_gecos = s;
if (!(s = strchr(s, ':'))) continue;
*s++ = 0; pw->pw_gecos = s;
if (!(s = strchr(s, ':'))) continue;
@@
-32,6
+43,8
@@
struct passwd *__getpwent_a(FILE *f, struct passwd *pw, char **line, size_t *siz
if (!(s = strchr(s, ':'))) continue;
*s++ = 0; pw->pw_shell = s;
if (!(s = strchr(s, ':'))) continue;
*s++ = 0; pw->pw_shell = s;
-
return pw
;
+
break
;
}
}
+ pthread_setcancelstate(cs, 0);
+ return pw;
}
}