about summary refs log tree commit diff
path: root/sysdeps/mach
diff options
context:
space:
mode:
authorPino Toscano <toscano.pino@tiscali.it>2012-07-21 00:06:33 +0200
committerPino Toscano <toscano.pino@tiscali.it>2012-07-21 00:06:33 +0200
commit0ced335ac081474e12c89709c81cf2f2094c5351 (patch)
treecb1426667fd71bcbf91ed98ed5a2a6e91dce1236 /sysdeps/mach
parent898c7aaba55cb348d4a94286cbaf7e2920f0cd82 (diff)
downloadglibc-0ced335ac081474e12c89709c81cf2f2094c5351.tar.gz
glibc-0ced335ac081474e12c89709c81cf2f2094c5351.tar.xz
glibc-0ced335ac081474e12c89709c81cf2f2094c5351.zip
Hurd: compliance fixes for getgroups
Fail with EINVAL when the requested number of groups is negative,
or when it is positive but less than the actual number of groups.
Diffstat (limited to 'sysdeps/mach')
-rw-r--r--sysdeps/mach/hurd/getgroups.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/sysdeps/mach/hurd/getgroups.c b/sysdeps/mach/hurd/getgroups.c
index 157a981740..35b219ef66 100644
--- a/sysdeps/mach/hurd/getgroups.c
+++ b/sysdeps/mach/hurd/getgroups.c
@@ -30,6 +30,9 @@ __getgroups (n, gidset)
   int ngids;
   void *crit;
 
+  if (n < 0)
+    return __hurd_fail (EINVAL);
+
   crit = _hurd_critical_section_lock ();
   __mutex_lock (&_hurd_id.lock);
 
@@ -53,7 +56,7 @@ __getgroups (n, gidset)
       /* Now that the lock is released, we can safely copy the
 	 group set into the user's array, which might fault.  */
       if (ngids > n)
-	ngids = n;
+	return __hurd_fail (EINVAL);
       memcpy (gidset, gids, ngids * sizeof (gid_t));
     }
   else