Print this page
3691 setgroups() needs a sorted GID list for more than 16 groups
Reviewed-By: Marcel Telka <marcel@telka.sk>
Reviewed-By: Richard Lowe <richlowe@richlowe.net>

@@ -17,10 +17,13 @@
  * information: Portions Copyright [yyyy] [name of copyright owner]
  *
  * CDDL HEADER END
  */
 /*
+ * Copyright (c) 2013, Ira Cooper.  All rights reserved.
+ */
+/*
  * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved.
  */
 
 /*      Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
 /*        All Rights Reserved   */

@@ -1438,10 +1441,11 @@
                 kmem_free(mem, sz);
                 return (NULL);
         }
         mem->crg_ref = 1;
         mem->crg_ngroups = n;
+        qsort(mem->crg_groups, n, sizeof (gid_t), gidcmp);
         return (mem);
 }
 
 const gid_t *
 crgetggroups(const credgrp_t *grps)