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