summaryrefslogtreecommitdiff
path: root/linux-user/syscall.c
diff options
context:
space:
mode:
authorDillon Amburgey <dillona@dillona.com>2013-02-02 18:04:48 -0500
committerRiku Voipio <riku.voipio@linaro.org>2013-03-11 13:05:08 +0200
commitf2b79ce9dc65753c6833921dd5ef6fa59632851f (patch)
treed3c0b956078d10f12bec9c1d00577f494be6a29f /linux-user/syscall.c
parentbfb669f39f2ecd854992924ced20b00163509043 (diff)
linux-user: Support setgroups syscall with no groups
Signed-off-by: Dillon Amburgey <dillona@dillona.com> Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
Diffstat (limited to 'linux-user/syscall.c')
-rw-r--r--linux-user/syscall.c22
1 files changed, 12 insertions, 10 deletions
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index c7fcfc02c6..1729446840 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -7680,18 +7680,20 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
{
int gidsetsize = arg1;
target_id *target_grouplist;
- gid_t *grouplist;
+ gid_t *grouplist = NULL;
int i;
-
- grouplist = alloca(gidsetsize * sizeof(gid_t));
- target_grouplist = lock_user(VERIFY_READ, arg2, gidsetsize * 2, 1);
- if (!target_grouplist) {
- ret = -TARGET_EFAULT;
- goto fail;
+ if (gidsetsize) {
+ grouplist = alloca(gidsetsize * sizeof(gid_t));
+ target_grouplist = lock_user(VERIFY_READ, arg2, gidsetsize * 2, 1);
+ if (!target_grouplist) {
+ ret = -TARGET_EFAULT;
+ goto fail;
+ }
+ for (i = 0; i < gidsetsize; i++) {
+ grouplist[i] = low2highgid(tswapid(target_grouplist[i]));
+ }
+ unlock_user(target_grouplist, arg2, 0);
}
- for(i = 0;i < gidsetsize; i++)
- grouplist[i] = low2highgid(tswapid(target_grouplist[i]));
- unlock_user(target_grouplist, arg2, 0);
ret = get_errno(setgroups(gidsetsize, grouplist));
}
break;