diff options
-rw-r--r-- | ChangeLog | 3 | ||||
-rw-r--r-- | sysdeps/mach/hurd/getgroups.c | 5 |
2 files changed, 7 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog index a804f2cf03..560bb95533 100644 --- a/ChangeLog +++ b/ChangeLog @@ -10,6 +10,9 @@ * sysdeps/mach/hurd/lremovexattr.c: New file, copied from removexattr.c with O_NOLINK passed to __file_name_lookup. + * sysdeps/mach/hurd/getgroups.c: Return -1 and set EINVAL for + negative N or less than NGIDS. + 2012-07-20 Joseph Myers <joseph@codesourcery.com> * elf/Makefile (check-data): Remove. 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 |