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. 2012-04-28 Pino Toscano * sysdeps/mach/hurd/getgroups.c: Return -1 and set EINVAL for negative N or less than NGIDS. --- a/sysdeps/mach/hurd/getgroups.c +++ b/sysdeps/mach/hurd/getgroups.c @@ -31,6 +31,9 @@ int ngids; void *crit; + if (n < 0) + return __hurd_fail (EINVAL); + crit = _hurd_critical_section_lock (); __mutex_lock (&_hurd_id.lock); @@ -54,7 +57,7 @@ /* 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