00db10
commit c3ec475c5dd16499aa040908e11d382c3ded9692
00db10
Author: Siddhesh Poyarekar <siddhesh@redhat.com>
00db10
Date:   Mon May 26 11:40:08 2014 +0530
00db10
00db10
    Use NSS_STATUS_TRYAGAIN to indicate insufficient buffer (BZ #16878)
00db10
    
00db10
    The netgroups nss modules in the glibc tree use NSS_STATUS_UNAVAIL
00db10
    (with errno as ERANGE) when the supplied buffer does not have
00db10
    sufficient space for the result.  This is wrong, because the canonical
00db10
    way to indicate insufficient buffer is to set the errno to ERANGE and
00db10
    the status to NSS_STATUS_TRYAGAIN, as is used by all other modules.
00db10
    
00db10
    This fixes nscd behaviour when the nss_ldap module returns
00db10
    NSS_STATUS_TRYAGAIN to indicate that a netgroup entry is too long to
00db10
    fit into the supplied buffer.
00db10
00db10
diff --git glibc-2.17-c758a686/nscd/netgroupcache.c glibc-2.17-c758a686/nscd/netgroupcache.c
00db10
index b3d40e9..edab174 100644
00db10
--- glibc-2.17-c758a686/nscd/netgroupcache.c
00db10
+++ glibc-2.17-c758a686/nscd/netgroupcache.c
00db10
@@ -197,11 +197,6 @@ addgetnetgrentX (struct database_dyn *db, int fd, request_header *req,
00db10
 		    int e;
00db10
 		    status = getfct.f (&data, buffer + buffilled,
00db10
 				       buflen - buffilled - req->key_len, &e);
00db10
-		    if (status == NSS_STATUS_RETURN
00db10
-			|| status == NSS_STATUS_NOTFOUND)
00db10
-		      /* This was either the last one for this group or the
00db10
-			 group was empty.  Look at next group if available.  */
00db10
-		      break;
00db10
 		    if (status == NSS_STATUS_SUCCESS)
00db10
 		      {
00db10
 			if (data.type == triple_val)
00db10
@@ -320,11 +315,18 @@ addgetnetgrentX (struct database_dyn *db, int fd, request_header *req,
00db10
 			      }
00db10
 			  }
00db10
 		      }
00db10
-		    else if (status == NSS_STATUS_UNAVAIL && e == ERANGE)
00db10
+		    else if (status == NSS_STATUS_TRYAGAIN && e == ERANGE)
00db10
 		      {
00db10
 			buflen *= 2;
00db10
 			buffer = xrealloc (buffer, buflen);
00db10
 		      }
00db10
+		    else if (status == NSS_STATUS_RETURN
00db10
+			     || status == NSS_STATUS_NOTFOUND
00db10
+			     || status == NSS_STATUS_UNAVAIL)
00db10
+		      /* This was either the last one for this group or the
00db10
+			 group was empty or the NSS module had an internal
00db10
+			 failure.  Look at next group if available.  */
00db10
+		      break;
00db10
 		  }
00db10
 
00db10
 	      enum nss_status (*endfct) (struct __netgrent *);
00db10
diff --git glibc-2.17-c758a686/nss/nss_files/files-netgrp.c glibc-2.17-c758a686/nss/nss_files/files-netgrp.c
00db10
index 34eae4c..bc0b367 100644
00db10
--- glibc-2.17-c758a686/nss/nss_files/files-netgrp.c
00db10
+++ glibc-2.17-c758a686/nss/nss_files/files-netgrp.c
00db10
@@ -252,7 +252,7 @@ _nss_netgroup_parseline (char **cursor, struct __netgrent *result,
00db10
   if (cp - host > buflen)
00db10
     {
00db10
       *errnop = ERANGE;
00db10
-      status = NSS_STATUS_UNAVAIL;
00db10
+      status = NSS_STATUS_TRYAGAIN;
00db10
     }
00db10
   else
00db10
     {