From 017c8132edae466e2892faec7ef6b834dfecbd34 Mon Sep 17 00:00:00 2001 From: Eric Andersen Date: Fri, 27 Jun 2003 10:43:43 +0000 Subject: Yet more cleanup for the reentrant pwd/grp functions so they should now actually be doing the right thing --- libc/pwd_grp/fgetpwent.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'libc/pwd_grp/fgetpwent.c') diff --git a/libc/pwd_grp/fgetpwent.c b/libc/pwd_grp/fgetpwent.c index 8917c29d0..174629fcb 100644 --- a/libc/pwd_grp/fgetpwent.c +++ b/libc/pwd_grp/fgetpwent.c @@ -34,12 +34,16 @@ static pthread_mutex_t mylock = PTHREAD_MUTEX_INITIALIZER; #endif int fgetpwent_r (FILE *file, struct passwd *password, - char *buff, size_t buflen, struct passwd **crap) + char *buff, size_t buflen, struct passwd **result) { + int res; if (file == NULL) { return EINTR; } - return(__getpwent_r(password, buff, buflen, fileno(file))); + *result = NULL; + res = __getpwent_r(password, buff, buflen, fileno(file)); + *result = password; + return res; } struct passwd *fgetpwent(FILE * file) @@ -47,9 +51,10 @@ struct passwd *fgetpwent(FILE * file) int ret; static char line_buff[PWD_BUFFER_SIZE]; static struct passwd pwd; + struct passwd *result; LOCK; - if ((ret=fgetpwent_r(file, &pwd, line_buff, sizeof(line_buff), NULL)) == 0) { + if ((ret=fgetpwent_r(file, &pwd, line_buff, sizeof(line_buff), &result)) == 0) { UNLOCK; return &pwd; } -- cgit v1.2.3