diff options
Diffstat (limited to 'nis/nss_nisplus/nisplus-pwd.c')
-rw-r--r-- | nis/nss_nisplus/nisplus-pwd.c | 42 |
1 files changed, 30 insertions, 12 deletions
diff --git a/nis/nss_nisplus/nisplus-pwd.c b/nis/nss_nisplus/nisplus-pwd.c index 459a1a4380..2c1fb19cab 100644 --- a/nis/nss_nisplus/nisplus-pwd.c +++ b/nis/nss_nisplus/nisplus-pwd.c @@ -96,8 +96,11 @@ internal_nisplus_getpwent_r (struct passwd *pw, char *buffer, size_t buflen) /* Get the next entry until we found a correct one. */ do { + nis_result *saved_res; + if (result == NULL) { + saved_res = NULL; if (tablename_val == NULL) if (_nss_create_tablename () != NSS_STATUS_SUCCESS) return NSS_STATUS_UNAVAIL; @@ -110,14 +113,28 @@ internal_nisplus_getpwent_r (struct passwd *pw, char *buffer, size_t buflen) { nis_result *res; + saved_res = result; res = nis_next_entry(tablename_val, &result->cookie); - nis_freeresult (result); result = res; if (niserr2nss (result->status) != NSS_STATUS_SUCCESS) - return niserr2nss (result->status); + { + nis_freeresult (saved_res); + return niserr2nss (result->status); + } } - parse_res = _nss_nisplus_parse_pwent (result, pw, buffer, buflen); + if ((parse_res = _nss_nisplus_parse_pwent (result, pw, buffer, + buflen)) == -1) + { + nis_freeresult (result); + result = saved_res; + return NSS_STATUS_TRYAGAIN; + } + else + { + if (saved_res) + nis_freeresult (saved_res); + } } while (!parse_res); return NSS_STATUS_SUCCESS; @@ -170,13 +187,13 @@ _nss_nisplus_getpwnam_r (const char *name, struct passwd *pw, nis_freeresult (result); + if (parse_res == -1) + return NSS_STATUS_TRYAGAIN; + if (parse_res) return NSS_STATUS_SUCCESS; - - if (!parse_res && errno == ERANGE) - return NSS_STATUS_TRYAGAIN; - else - return NSS_STATUS_NOTFOUND; + + return NSS_STATUS_NOTFOUND; } } @@ -207,12 +224,13 @@ _nss_nisplus_getpwuid_r (const uid_t uid, struct passwd *pw, parse_res = _nss_nisplus_parse_pwent (result, pw, buffer, buflen); nis_freeresult (result); + + if (parse_res == -1) + return NSS_STATUS_TRYAGAIN; + if (parse_res) return NSS_STATUS_SUCCESS; - if (!parse_res && errno == ERANGE) - return NSS_STATUS_TRYAGAIN; - else - return NSS_STATUS_NOTFOUND; + return NSS_STATUS_NOTFOUND; } } |