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/getpwnam.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'libc/pwd_grp/getpwnam.c') diff --git a/libc/pwd_grp/getpwnam.c b/libc/pwd_grp/getpwnam.c index 6f041e2d8..7e81fa081 100644 --- a/libc/pwd_grp/getpwnam.c +++ b/libc/pwd_grp/getpwnam.c @@ -42,6 +42,8 @@ int getpwnam_r (const char *name, struct passwd *password, int ret; int passwd_fd; + *result = NULL; + if (name == NULL) { return EINVAL; } @@ -54,6 +56,7 @@ int getpwnam_r (const char *name, struct passwd *password, if (!strcmp(password->pw_name, name)) { *result=password; close(passwd_fd); + *result = password; return 0; } } @@ -66,7 +69,8 @@ struct passwd *getpwnam(const char *name) { int ret; static char line_buff[PWD_BUFFER_SIZE]; - static struct passwd pwd, *result; + static struct passwd pwd; + struct passwd *result; LOCK; if ((ret=getpwnam_r(name, &pwd, line_buff, sizeof(line_buff), &result)) == 0) { -- cgit v1.2.3