arrfab / rpms / glibc

Forked from rpms/glibc 5 years ago
Clone

Blame SOURCES/glibc-rh1173537.patch

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