Commit cb3bc23361830872663395de112c2c76ff00be50
1 parent
e856f2ad
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
Showing
1 changed file
with
4 additions
and
0 deletions
linux-user/syscall.c
... | ... | @@ -5247,6 +5247,8 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1, |
5247 | 5247 | |
5248 | 5248 | grouplist = alloca(gidsetsize * sizeof(gid_t)); |
5249 | 5249 | ret = get_errno(getgroups(gidsetsize, grouplist)); |
5250 | + if (gidsetsize == 0) | |
5251 | + break; | |
5250 | 5252 | if (!is_error(ret)) { |
5251 | 5253 | target_grouplist = lock_user(VERIFY_WRITE, arg2, gidsetsize * 2, 0); |
5252 | 5254 | if (!target_grouplist) |
... | ... | @@ -5397,6 +5399,8 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1, |
5397 | 5399 | |
5398 | 5400 | grouplist = alloca(gidsetsize * sizeof(gid_t)); |
5399 | 5401 | ret = get_errno(getgroups(gidsetsize, grouplist)); |
5402 | + if (gidsetsize == 0) | |
5403 | + break; | |
5400 | 5404 | if (!is_error(ret)) { |
5401 | 5405 | target_grouplist = lock_user(VERIFY_WRITE, arg2, gidsetsize * 4, 0); |
5402 | 5406 | if (!target_grouplist) { | ... | ... |