diff options
Diffstat (limited to 'libc/pwd_grp/pwent.c')
-rw-r--r-- | libc/pwd_grp/pwent.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/libc/pwd_grp/pwent.c b/libc/pwd_grp/pwent.c index f79be7f33..f70a6e378 100644 --- a/libc/pwd_grp/pwent.c +++ b/libc/pwd_grp/pwent.c @@ -67,23 +67,27 @@ void endpwent(void) int getpwent_r (struct passwd *password, char *buff, size_t buflen, struct passwd **crap) { + int ret; LOCK; - if (pw_fd != -1 && __getpwent_r(password, buff, buflen, pw_fd) != -1) { + if (pw_fd != -1 && (ret=__getpwent_r(password, buff, buflen, pw_fd)) == 0) { UNLOCK; return 0; } UNLOCK; - return -1; + __set_errno(ret); + return ret; } struct passwd *getpwent(void) { + int ret; static char line_buff[PWD_BUFFER_SIZE]; static struct passwd pwd; - if (getpwent_r(&pwd, line_buff, sizeof(line_buff), NULL) != -1) { + if ((ret=getpwent_r(&pwd, line_buff, sizeof(line_buff), NULL)) == 0) { return &pwd; } + __set_errno(ret); return NULL; } |