Return proper status from _nss_nis_initgroups_dyn (bug 20262)
authorAndreas Schwab <schwab@suse.de>
Thu, 16 Jun 2016 10:44:29 +0000 (12:44 +0200)
committerAndreas Schwab <schwab@suse.de>
Thu, 30 Jun 2016 11:55:36 +0000 (13:55 +0200)
ChangeLog
nis/nss_nis/nis-initgroups.c

index f7803ee..9131b1f 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2016-06-30  Andreas Schwab  <schwab@suse.de>
+
+       [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.
+
 2016-06-29  H.J. Lu  <hongjiu.lu@intel.com>
 
        [BZ #18645]
index dec385c..0368667 100644 (file)
@@ -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)