aboutsummaryrefslogtreecommitdiff
path: root/linux-user
diff options
context:
space:
mode:
authorbalrog <balrog@c046a42c-6fe2-441c-8c8c-71466251a162>2008-09-20 02:08:13 +0000
committerbalrog <balrog@c046a42c-6fe2-441c-8c8c-71466251a162>2008-09-20 02:08:13 +0000
commitcb3bc23361830872663395de112c2c76ff00be50 (patch)
treee2bc1362b82807cd7ae10939bd6c51e4366d99f9 /linux-user
parente856f2ad014e6cb1bd3eca126be23b8f919f3dd1 (diff)
downloadqemu-cb3bc23361830872663395de112c2c76ff00be50.zip
qemu-cb3bc23361830872663395de112c2c76ff00be50.tar.gz
qemu-cb3bc23361830872663395de112c2c76ff00be50.tar.bz2
Fix getgroups() with zero size parameter (Kirill Shutemov).
According to man page getgroups(2): If size is zero, list is not modified, but the total number of supplementary group IDs for the process is returned. Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name> git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@5266 c046a42c-6fe2-441c-8c8c-71466251a162
Diffstat (limited to 'linux-user')
-rw-r--r--linux-user/syscall.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 56b4138..4ba8880 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -5247,6 +5247,8 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
grouplist = alloca(gidsetsize * sizeof(gid_t));
ret = get_errno(getgroups(gidsetsize, grouplist));
+ if (gidsetsize == 0)
+ break;
if (!is_error(ret)) {
target_grouplist = lock_user(VERIFY_WRITE, arg2, gidsetsize * 2, 0);
if (!target_grouplist)
@@ -5397,6 +5399,8 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
grouplist = alloca(gidsetsize * sizeof(gid_t));
ret = get_errno(getgroups(gidsetsize, grouplist));
+ if (gidsetsize == 0)
+ break;
if (!is_error(ret)) {
target_grouplist = lock_user(VERIFY_WRITE, arg2, gidsetsize * 4, 0);
if (!target_grouplist) {