svn commit: samba r2452 - in trunk/source/nsswitch: .

jra at samba.org jra at samba.org
Mon Sep 20 20:18:26 GMT 2004


Author: jra
Date: 2004-09-20 20:18:24 +0000 (Mon, 20 Sep 2004)
New Revision: 2452

WebSVN: http://websvn.samba.org/websvn/changeset.php?rep=samba&path=/trunk/source/nsswitch&rev=2452&nolog=1

Log:
Fix from Henrik Nordstrom <hno at squid-cache.org> to allow
winbindd to return the correct number of groups when the
groups array must be enlarged.
Jeremy.

Modified:
   trunk/source/nsswitch/winbind_nss_linux.c


Changeset:
Modified: trunk/source/nsswitch/winbind_nss_linux.c
===================================================================
--- trunk/source/nsswitch/winbind_nss_linux.c	2004-09-20 20:18:19 UTC (rev 2451)
+++ trunk/source/nsswitch/winbind_nss_linux.c	2004-09-20 20:18:24 UTC (rev 2452)
@@ -833,25 +833,38 @@
 
 			/* Skip primary group */
 
-			if (gid_list[i] == group) continue;
+			if (gid_list[i] == group) {
+				continue;
+			}
 
-			/* Add to buffer */
+			/* Filled buffer ? If so, resize. */
 
-			if (*start == *size && limit <= 0) {
-				(*groups) = realloc(
-					(*groups), (2 * (*size) + 1) * sizeof(**groups));
-				if (! *groups) goto done;
-				*size = 2 * (*size) + 1;
+			if (*start == *size) {
+				long int newsize;
+				gid_t *newgroups;
+
+				newsize = 2 * (*size);
+				if (limit > 0) {
+					if (*size == limit) {
+						goto done;
+					}
+					newsize = MIN(newsize, limit);
+				}
+
+				newgroups = realloc((*groups), newsize * sizeof(**groups));
+				if (!newgroups) {
+					*errnop = ENOMEM;
+					ret = NSS_STATUS_NOTFOUND;
+					goto done;
+				}
+				*groups = newgroups;
+				*size = newsize;
 			}
 
-			if (*start == *size) goto done;
+			/* Add to buffer */
 
 			(*groups)[*start] = gid_list[i];
 			*start += 1;
-
-			/* Filled buffer? */
-
-			if (*start == limit) goto done;
 		}
 	}
 	



More information about the samba-cvs mailing list