qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Kirill A. Shutemov" <k.shutemov@velesys.com>
To: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [patch] fix getgroups and getgroups32 syscalls
Date: Sat, 8 Dec 2007 14:50:51 +0200	[thread overview]
Message-ID: <20071208125051.GA18930@localhost.localdomain> (raw)
In-Reply-To: <9c10c9f0712071517k3832dea4te2706e302c085e2f@mail.gmail.com>

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

On [Fri, 07.12.2007 20:17], Lauro Ramos Venancio wrote:
> 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

> 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;

This patch is too noisy, I think. My patch:

diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index ad97871..96a11a9 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -5029,6 +5029,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)
@@ -5179,6 +5181,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) {



-- 
Regards,  Kirill A. Shutemov
 + Belarus, Minsk
 + Velesys LLC, http://www.velesys.com/
 + ALT Linux Team, http://www.altlinux.com/

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 189 bytes --]

      reply	other threads:[~2007-12-08 12:49 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20071208125051.GA18930@localhost.localdomain \
    --to=k.shutemov@velesys.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).