diff options
author | Ulrich Drepper <drepper@redhat.com> | 1997-12-09 23:43:43 +0000 |
---|---|---|
committer | Ulrich Drepper <drepper@redhat.com> | 1997-12-09 23:43:43 +0000 |
commit | ee28823eee8bb26ec6326db40a3a69463ed4c51a (patch) | |
tree | 8b9e13156456c3bc547ad6765630324c60a46306 | |
parent | 50093870ac3521e97557dd1e8c3f0b247f86859c (diff) |
If buffer is to small, set the file handle for /etc/passwd back in
some more cases.
-rw-r--r-- | nis/nss_compat/compat-pwd.c | 32 |
1 files changed, 28 insertions, 4 deletions
diff --git a/nis/nss_compat/compat-pwd.c b/nis/nss_compat/compat-pwd.c index 048d1e9e49..4bf3dd2150 100644 --- a/nis/nss_compat/compat-pwd.c +++ b/nis/nss_compat/compat-pwd.c @@ -557,7 +557,16 @@ getpwent_next_file (struct passwd *result, ent_t *ent, fgetpos (ent->stream, &pos); p = fgets (buffer, buflen, ent->stream); if (p == NULL) - return NSS_STATUS_NOTFOUND; + { + if (feof (ent->stream)) + return NSS_STATUS_NOTFOUND; + else + { + fsetpos (ent->stream, &pos); + __set_errno (ERANGE); + return NSS_STATUS_TRYAGAIN; + } + } /* Terminate the line for any case. */ buffer[buflen - 1] = '\0'; @@ -732,6 +741,7 @@ internal_getpwnam_r (const char *name, struct passwd *result, ent_t *ent, return NSS_STATUS_NOTFOUND; else { + fsetpos (ent->stream, &pos); __set_errno (ERANGE); return NSS_STATUS_TRYAGAIN; } @@ -963,8 +973,17 @@ internal_getpwuid_r (uid_t uid, struct passwd *result, ent_t *ent, fgetpos (ent->stream, &pos); p = fgets (buffer, buflen, ent->stream); if (p == NULL) - return NSS_STATUS_NOTFOUND; - + { + if (feof (ent->stream)) + return NSS_STATUS_NOTFOUND; + else + { + fsetpos (ent->stream, &pos); + __set_errno (ERANGE); + return NSS_STATUS_TRYAGAIN; + } + } + /* Terminate the line for any case. */ buffer[buflen - 1] = '\0'; @@ -1076,7 +1095,12 @@ internal_getpwuid_r (uid_t uid, struct passwd *result, ent_t *ent, if (status == NSS_STATUS_RETURN) /* We couldn't parse the entry */ return NSS_STATUS_NOTFOUND; else - return status; + { + if (status == NSS_STATUS_TRYAGAIN) + /* The parser ran out of space */ + fsetpos (ent->stream, &pos); + return status; + } } } return NSS_STATUS_SUCCESS; |