From patchwork Thu Jun 16 14:06:39 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Schwab X-Patchwork-Id: 13137 Received: (qmail 105784 invoked by alias); 16 Jun 2016 14:06:54 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 105773 invoked by uid 89); 16 Jun 2016 14:06:53 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.3 required=5.0 tests=BAYES_00, RP_MATCHES_RCVD, SPF_PASS autolearn=ham version=3.3.2 spammy=buflen, Hx-languages-length:1705 X-HELO: mx2.suse.de From: Andreas Schwab To: Florian Weimer Cc: GNU C Library Subject: [PATCH] Return proper status from _nss_nis_initgroups_dyn (bug 20262) References: <54EF320A.90409@redhat.com> X-Yow: In Newark the laundromats are open 24 hours a day! Date: Thu, 16 Jun 2016 16:06:39 +0200 In-Reply-To: <54EF320A.90409@redhat.com> (Florian Weimer's message of "Thu, 26 Feb 2015 15:47:38 +0100") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) MIME-Version: 1.0 [BZ #20262] * nis/nss_nis/nis-initgroups.c (_nss_nis_initgroups_dyn): Return NSS_STATUS_SUCCESS when done. Return NSS_STATUS_TRYAGAIN when out of memory. --- nis/nss_nis/nis-initgroups.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/nis/nss_nis/nis-initgroups.c b/nis/nss_nis/nis-initgroups.c index dec385c..0368667 100644 --- a/nis/nss_nis/nis-initgroups.c +++ b/nis/nss_nis/nis-initgroups.c @@ -266,7 +266,7 @@ _nss_nis_initgroups_dyn (const char *user, gid_t group, long int *start, tmpbuf = __alloca (buflen); - do + while (1) { while ((status = internal_getgrent_r (&grpbuf, tmpbuf, buflen, errnop, @@ -275,8 +275,11 @@ _nss_nis_initgroups_dyn (const char *user, gid_t group, long int *start, tmpbuf = extend_alloca (tmpbuf, buflen, 2 * buflen); if (status != NSS_STATUS_SUCCESS) - goto done; - + { + if (status == NSS_STATUS_NOTFOUND) + status = NSS_STATUS_SUCCESS; + goto done; + } g = &grpbuf; if (g->gr_gid != group) @@ -304,7 +307,11 @@ _nss_nis_initgroups_dyn (const char *user, gid_t group, long int *start, newgroups = realloc (groups, newsize * sizeof (*groups)); if (newgroups == NULL) - goto done; + { + status = NSS_STATUS_TRYAGAIN; + *errnop = errno; + goto done; + } *groupsp = groups = newgroups; *size = newsize; } @@ -316,7 +323,6 @@ _nss_nis_initgroups_dyn (const char *user, gid_t group, long int *start, } } } - while (status == NSS_STATUS_SUCCESS); done: while (intern.start != NULL)