From 6fecfd9159d73b3839dbbc8910a2e1a5bef2d350 Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Mon, 30 Mar 1998 17:47:02 +0000 Subject: [PATCH] (REENTRANT_GETNAME): Avoid endless loop. --- nss/getXXent_r.c | 40 ++++++++++++++++++---------------------- 1 file changed, 18 insertions(+), 22 deletions(-) diff --git a/nss/getXXent_r.c b/nss/getXXent_r.c index 91be88739dc..1b50c02dc81 100644 --- a/nss/getXXent_r.c +++ b/nss/getXXent_r.c @@ -242,7 +242,6 @@ INTERNAL (REENTRANT_GETNAME) (LOOKUP_TYPE *resbuf, char *buffer, size_t buflen, while (! no_more) { int is_last_nip = nip == last_nip; - service_user *current_nip = nip; status = (*fct) (resbuf, buffer, buflen H_ERRNO_VAR); @@ -258,32 +257,29 @@ INTERNAL (REENTRANT_GETNAME) (LOOKUP_TYPE *resbuf, char *buffer, size_t buflen, && errno == ERANGE) break; - no_more = __nss_next (&nip, GETFUNC_NAME_STRING, (void **) &fct, - status, 0); + do + { + no_more = __nss_next (&nip, GETFUNC_NAME_STRING, (void **) &fct, + status, 0); - if (is_last_nip) - last_nip = nip; + if (is_last_nip) + last_nip = nip; - if (! no_more && current_nip != nip) - /* Call the `setXXent' function. This wasn't done before. */ - do - { - set_function sfct; + if (! no_more) + { + /* Call the `setXXent' function. This wasn't done before. */ + set_function sfct; - no_more = __nss_lookup (&nip, SETFUNC_NAME_STRING, - (void **) &sfct); + no_more = __nss_lookup (&nip, SETFUNC_NAME_STRING, + (void **) &sfct); - if (! no_more) - status = (*sfct) (STAYOPEN_TMPVAR); - else - { + if (! no_more) + status = (*sfct) (STAYOPEN_TMPVAR); + else status = NSS_STATUS_NOTFOUND; - if (no_more == 1) - /* There is no more module to search. */ - break; - } - } - while (! no_more && status != NSS_STATUS_SUCCESS); + } + } + while (! no_more && status != NSS_STATUS_SUCCESS); } __libc_lock_unlock (lock); -- 2.47.2