qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH] linux-user, fix getgroups/getgroups32 when both arg


From: Takashi Yoshii
Subject: [Qemu-devel] [PATCH] linux-user, fix getgroups/getgroups32 when both args are zero.
Date: Sat, 23 Feb 2008 12:00:23 +0900

getgroups() and getgroups32() returns NGROUPS_MAX when both its two args are
zero. But because we pass a ptr to allocated space as 2nd arg, this function
are interfered. The patch attached fixed it.
/yoshii
---
    linux-user/syscall.c: fix getgroups{,32} when both args are zero.

diff --git a/linux-user/syscall.c b/linux-user/syscall.c
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -5185,7 +5185,9 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
         ret = get_errno(setregid(low2highgid(arg1), low2highgid(arg2)));
         break;
     case TARGET_NR_getgroups:
-        {
+        if (arg1 == 0 && arg2 == 0)
+            ret = get_errno(getgroups(0, 0));
+        else {
             int gidsetsize = arg1;
             uint16_t *target_grouplist;
             gid_t *grouplist;
@@ -5335,7 +5337,9 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
 #endif
 #ifdef TARGET_NR_getgroups32
     case TARGET_NR_getgroups32:
-        {
+        if (arg1 == 0 && arg2 == 0)
+            ret = get_errno(getgroups(0, 0));
+        else {
             int gidsetsize = arg1;
             uint32_t *target_grouplist;
             gid_t *grouplist;




reply via email to

[Prev in Thread] Current Thread [Next in Thread]