diff options
Diffstat (limited to 'libc')
-rw-r--r-- | libc/pwd_grp/__getgrent_r.c | 3 | ||||
-rw-r--r-- | libc/pwd_grp/__getpwent_r.c | 3 | ||||
-rw-r--r-- | libc/pwd_grp/pwent.c | 3 |
3 files changed, 8 insertions, 1 deletions
diff --git a/libc/pwd_grp/__getgrent_r.c b/libc/pwd_grp/__getgrent_r.c index 69559bdb1..d5b2e99f1 100644 --- a/libc/pwd_grp/__getgrent_r.c +++ b/libc/pwd_grp/__getgrent_r.c @@ -44,6 +44,9 @@ int __getgrent_r (struct group *__restrict group, return ERANGE; } + if (grp_fd==-1) + setgrent(); + /* We use the restart label to handle malformatted lines */ restart: /* Read the group line into the buffer for processing */ 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 */ diff --git a/libc/pwd_grp/pwent.c b/libc/pwd_grp/pwent.c index e3488f4f5..b2c149b35 100644 --- a/libc/pwd_grp/pwent.c +++ b/libc/pwd_grp/pwent.c @@ -72,7 +72,8 @@ int getpwent_r (struct passwd *password, char *buff, int ret=EINVAL; LOCK; *result = NULL; - if (pw_fd != -1 && (ret=__getpwent_r(password, buff, buflen, pw_fd)) == 0) { + + if ((ret=__getpwent_r(password, buff, buflen, pw_fd)) == 0) { UNLOCK; *result = password; return 0; |