Patchwork linux-user: fix setgroups/getgroups for non-UID16 archs

login
register
mail settings
Submitter Andreas Schwab
Date April 9, 2013, 3:41 p.m.
Message ID <mvmvc7v1zki.fsf@hawking.suse.de>
Download mbox | patch
Permalink /patch/235118/
State New
Headers show

Comments

Andreas Schwab - April 9, 2013, 3:41 p.m.
Don't assume target_id is a short.

Signed-off-by: Andreas Schwab <schwab@suse.de>
---
 linux-user/syscall.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Patch

diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index d3c26de..3f13d0b 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -7800,12 +7800,12 @@  abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
             if (gidsetsize == 0)
                 break;
             if (!is_error(ret)) {
-                target_grouplist = lock_user(VERIFY_WRITE, arg2, gidsetsize * 2, 0);
+                target_grouplist = lock_user(VERIFY_WRITE, arg2, gidsetsize * sizeof(target_id), 0);
                 if (!target_grouplist)
                     goto efault;
                 for(i = 0;i < ret; i++)
                     target_grouplist[i] = tswapid(high2lowgid(grouplist[i]));
-                unlock_user(target_grouplist, arg2, gidsetsize * 2);
+                unlock_user(target_grouplist, arg2, gidsetsize * sizeof(target_id));
             }
         }
         break;
@@ -7817,7 +7817,7 @@  abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
             int i;
             if (gidsetsize) {
                 grouplist = alloca(gidsetsize * sizeof(gid_t));
-                target_grouplist = lock_user(VERIFY_READ, arg2, gidsetsize * 2, 1);
+                target_grouplist = lock_user(VERIFY_READ, arg2, gidsetsize * sizeof(target_id), 1);
                 if (!target_grouplist) {
                     ret = -TARGET_EFAULT;
                     goto fail;