diff options
Diffstat (limited to 'src/passwd/getpwent_a.c')
-rw-r--r-- | src/passwd/getpwent_a.c | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/src/passwd/getpwent_a.c b/src/passwd/getpwent_a.c index 1bd7f4fc..34842a07 100644 --- a/src/passwd/getpwent_a.c +++ b/src/passwd/getpwent_a.c @@ -1,6 +1,13 @@ #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; @@ -23,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_uid = atoi(s); - if (!(s = strchr(s, ':'))) continue; + *s++ = 0; pw->pw_uid = atou(&s); + if (*s != ':') continue; - *s++ = 0; pw->pw_gid = atoi(s); - if (!(s = strchr(s, ':'))) continue; + *s++ = 0; pw->pw_gid = atou(&s); + if (*s != ':') continue; *s++ = 0; pw->pw_gecos = s; if (!(s = strchr(s, ':'))) continue; |