about summary refs log tree commit diff
path: root/nscd/initgrcache.c
diff options
context:
space:
mode:
Diffstat (limited to 'nscd/initgrcache.c')
-rw-r--r--nscd/initgrcache.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/nscd/initgrcache.c b/nscd/initgrcache.c
index 124b4bae62..9ba7b89bdf 100644
--- a/nscd/initgrcache.c
+++ b/nscd/initgrcache.c
@@ -117,6 +117,7 @@ addinitgroupsX (struct database_dyn *db, int fd, request_header *req,
   /* Nothing added yet.  */
   while (! no_more)
     {
+      long int prev_start = start;
       enum nss_status status;
       initgroups_dyn_function fct;
       fct = __nss_lookup_function (nip, "initgroups_dyn");
@@ -133,6 +134,21 @@ addinitgroupsX (struct database_dyn *db, int fd, request_header *req,
 	status = DL_CALL_FCT (fct, (key, -1, &start, &size, &groups,
 				    limit, &errno));
 
+      /* Remove duplicates.  */
+      long int cnt = prev_start;
+      while (cnt < start)
+	{
+	  long int inner;
+	  for (inner = 0; inner < prev_start; ++inner)
+	    if ((*groupsp)[inner] == (*groups)[cnt])
+	      break;
+
+	  if (inner < prev_start)
+	    ++cnt;
+	  else
+	    (*groupsp)[cnt] = (*groupsp)[--start];
+	}
+
       if (status != NSS_STATUS_TRYAGAIN)
 	all_tryagain = false;