From fff9c70e33036a80875dc25d359ef22c2c0a524c Mon Sep 17 00:00:00 2001 From: Eric Andersen Date: Fri, 31 Oct 2003 20:17:01 +0000 Subject: getpwent(), getpwent_r(), and getgrent(), getgrent_r() would all fail if you had not previously called setpwent() or setgrent() respectively. Oops. My bad. -Erik --- libc/pwd_grp/__getpwent_r.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'libc/pwd_grp/__getpwent_r.c') diff --git a/libc/pwd_grp/__getpwent_r.c b/libc/pwd_grp/__getpwent_r.c index 6e6de4038..7614b7edf 100644 --- a/libc/pwd_grp/__getpwent_r.c +++ b/libc/pwd_grp/__getpwent_r.c @@ -47,6 +47,9 @@ int __getpwent_r(struct passwd * passwd, char * line_buff, size_t buflen, int pw return ERANGE; } + if (pw_fd == -1) + setpwent(); + /* We use the restart label to handle malformatted lines */ restart: /* Read the passwd line into the buffer for processing */ -- cgit v1.2.3