From patchwork Mon Mar 11 19:27:42 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Riku Voipio X-Patchwork-Id: 226650 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 9790C2C02C7 for ; Tue, 12 Mar 2013 06:28:59 +1100 (EST) Received: from localhost ([::1]:57344 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UF8P3-00009y-Nr for incoming@patchwork.ozlabs.org; Mon, 11 Mar 2013 15:28:57 -0400 Received: from eggs.gnu.org ([208.118.235.92]:52387) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UF8O9-0007m7-SK for qemu-devel@nongnu.org; Mon, 11 Mar 2013 15:28:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UF8O1-00031Y-3n for qemu-devel@nongnu.org; Mon, 11 Mar 2013 15:28:01 -0400 Received: from afflict.kos.to ([92.243.29.197]:34979) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UF8O0-000319-Sq for qemu-devel@nongnu.org; Mon, 11 Mar 2013 15:27:53 -0400 Received: from kos.to (a91-156-58-157.elisa-laajakaista.fi [91.156.58.157]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by afflict.kos.to (Postfix) with ESMTPSA id 27B7F26550 for ; Mon, 11 Mar 2013 20:27:50 +0100 (CET) Received: from voipio (uid 1000) (envelope-from voipio@kos.to) id 5e0e05 by kos.to (DragonFly Mail Agent); Mon, 11 Mar 2013 21:27:49 +0200 From: riku.voipio@linaro.org To: qemu-devel@nongnu.org Date: Mon, 11 Mar 2013 21:27:42 +0200 Message-Id: X-Mailer: git-send-email 1.7.10.4 In-Reply-To: References: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 92.243.29.197 Cc: Dillon Amburgey Subject: [Qemu-devel] [PATCH 05/11] linux-user: Support setgroups syscall with no groups X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Dillon Amburgey Signed-off-by: Dillon Amburgey Reviewed-by: Peter Maydell Signed-off-by: Riku Voipio --- linux-user/syscall.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index c7fcfc0..1729446 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -7680,18 +7680,20 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1, { int gidsetsize = arg1; target_id *target_grouplist; - gid_t *grouplist; + gid_t *grouplist = NULL; int i; - - grouplist = alloca(gidsetsize * sizeof(gid_t)); - target_grouplist = lock_user(VERIFY_READ, arg2, gidsetsize * 2, 1); - if (!target_grouplist) { - ret = -TARGET_EFAULT; - goto fail; + if (gidsetsize) { + grouplist = alloca(gidsetsize * sizeof(gid_t)); + target_grouplist = lock_user(VERIFY_READ, arg2, gidsetsize * 2, 1); + if (!target_grouplist) { + ret = -TARGET_EFAULT; + goto fail; + } + for (i = 0; i < gidsetsize; i++) { + grouplist[i] = low2highgid(tswapid(target_grouplist[i])); + } + unlock_user(target_grouplist, arg2, 0); } - for(i = 0;i < gidsetsize; i++) - grouplist[i] = low2highgid(tswapid(target_grouplist[i])); - unlock_user(target_grouplist, arg2, 0); ret = get_errno(setgroups(gidsetsize, grouplist)); } break;