]> sourceware.org Git - glibc.git/commitdiff
Hurd: compliance fixes for getgroups
authorPino Toscano <toscano.pino@tiscali.it>
Fri, 20 Jul 2012 22:06:33 +0000 (00:06 +0200)
committerPino Toscano <toscano.pino@tiscali.it>
Fri, 20 Jul 2012 22:06:33 +0000 (00:06 +0200)
Fail with EINVAL when the requested number of groups is negative,
or when it is positive but less than the actual number of groups.

ChangeLog
sysdeps/mach/hurd/getgroups.c

index a804f2cf03ed3bf36ab3b948b803bcc22e35a657..560bb95533fc792f819e8605c2c923bed92101d3 100644 (file)
--- 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.
index 157a981740f2952f58c891f30f2f413a22598b58..35b219ef66c366065ed53cc7f593964a6651071a 100644 (file)
@@ -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
This page took 0.112203 seconds and 5 git commands to generate.