This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
| Other format: | [Raw text] | |
Hi, attached there is a patch to fix a couple of issues with Hurd's getgroups(), namely when the requested number is < 0 or when it is > 0 but less than the actual number of groups that would be returned (this case is handled by simply returning the first n groups, instead of failing). Thanks, -- Pino Toscano
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-27 Pino Toscano <toscano.pino@tiscali.it>
* sysdeps/mach/hurd/getgroups.c (__getgroups): Return -1 and set EINVAL
for negative `n' or less than `ngids'.
--- 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
Attachment:
signature.asc
Description: This is a digitally signed message part.
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |