qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [patch] fix getgroups and getgroups32 syscalls
@ 2007-12-07 23:17 Lauro Ramos Venancio
  2007-12-08 12:50 ` Kirill A. Shutemov
  0 siblings, 1 reply; 2+ messages in thread
From: Lauro Ramos Venancio @ 2007-12-07 23:17 UTC (permalink / raw)
  To: qemu-devel

[-- Attachment #1: Type: text/plain, Size: 354 bytes --]

The attached patch fixes a bug in getgroups and getgroups32 syscalls.
The current implementation returns error when size=0.

According the manual:
" If size is zero, list is not modified, but the total number of
supplementary group IDs for the process is returned."

--
Lauro Ramos Venancio
OpenBossa Labs - Instituto Nokia de Tecnologia
Recife - Brazil

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 00_fix_getgroups.patch --]
[-- Type: text/x-patch; name=00_fix_getgroups.patch, Size: 1608 bytes --]

Index: qemu-arm-eabi/linux-user/syscall.c
===================================================================
--- qemu-arm-eabi.orig/linux-user/syscall.c	2007-12-07 19:59:03.000000000 -0300
+++ qemu-arm-eabi/linux-user/syscall.c	2007-12-07 20:01:47.000000000 -0300
@@ -5024,12 +5024,13 @@
         {
             int gidsetsize = arg1;
             uint16_t *target_grouplist;
-            gid_t *grouplist;
+            gid_t *grouplist = NULL;
             int i;
 
-            grouplist = alloca(gidsetsize * sizeof(gid_t));
+            if (gidsetsize)
+                grouplist = alloca(gidsetsize * sizeof(gid_t));
             ret = get_errno(getgroups(gidsetsize, grouplist));
-            if (!is_error(ret)) {
+            if (gidsetsize && !is_error(ret)) {
                 target_grouplist = lock_user(VERIFY_WRITE, arg2, gidsetsize * 2, 0);
                 if (!target_grouplist)
                     goto efault;
@@ -5174,12 +5175,13 @@
         {
             int gidsetsize = arg1;
             uint32_t *target_grouplist;
-            gid_t *grouplist;
+            gid_t *grouplist = NULL;
             int i;
 
-            grouplist = alloca(gidsetsize * sizeof(gid_t));
+            if (gidsetsize)
+                grouplist = alloca(gidsetsize * sizeof(gid_t));
             ret = get_errno(getgroups(gidsetsize, grouplist));
-            if (!is_error(ret)) {
+            if (gidsetsize && !is_error(ret)) {
                 target_grouplist = lock_user(VERIFY_WRITE, arg2, gidsetsize * 4, 0);
                 if (!target_grouplist) {
                     ret = -TARGET_EFAULT;

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2007-12-08 12:49 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-12-07 23:17 [Qemu-devel] [patch] fix getgroups and getgroups32 syscalls Lauro Ramos Venancio
2007-12-08 12:50 ` Kirill A. Shutemov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).