From patchwork Mon May 15 14:59:52 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Milos Stojanovic X-Patchwork-Id: 762566 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3wRP8G0jlHz9s0g for ; Tue, 16 May 2017 01:07:42 +1000 (AEST) Received: from localhost ([::1]:37293 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dAHb1-0004Nb-Fd for incoming@patchwork.ozlabs.org; Mon, 15 May 2017 11:07:39 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38566) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dAHaH-0004KC-Tl for qemu-devel@nongnu.org; Mon, 15 May 2017 11:06:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dAHaC-0006nc-Vv for qemu-devel@nongnu.org; Mon, 15 May 2017 11:06:53 -0400 Received: from mx2.rt-rk.com ([89.216.37.149]:47181 helo=mail.rt-rk.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dAHaC-0006nH-Nq for qemu-devel@nongnu.org; Mon, 15 May 2017 11:06:48 -0400 Received: from localhost (localhost [127.0.0.1]) by mail.rt-rk.com (Postfix) with ESMTP id 517D61A45A2; Mon, 15 May 2017 17:06:47 +0200 (CEST) X-Virus-Scanned: amavisd-new at rt-rk.com Received: from rtrkw488-lin.domain.local (unknown [10.10.14.90]) by mail.rt-rk.com (Postfix) with ESMTPSA id 38A2D1A459D; Mon, 15 May 2017 17:06:47 +0200 (CEST) From: =?UTF-8?q?Milo=C5=A1=20Stojanovi=C4=87?= To: qemu-devel@nongnu.org, riku.voipio@iki.fi Date: Mon, 15 May 2017 16:59:52 +0200 Message-Id: <1494860396-24930-13-git-send-email-Milos.Stojanovic@rt-rk.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1494860396-24930-1-git-send-email-Milos.Stojanovic@rt-rk.com> References: <1494860396-24930-1-git-send-email-Milos.Stojanovic@rt-rk.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 89.216.37.149 Subject: [Qemu-devel] [PATCH v2 12/16] [RFC] linux-user: fix sigismember() check X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Miodrag.Dinic@rt-rk.com, laurent@vivier.eu, Petar.Jovanovic@rt-rk.com, Aleksandar.Markovic@rt-rk.com, yongbok.kim@imgtec.com, Milos.Stojanovic@rt-rk.com Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Fix copying between the host and target signal sets for the case when the target set is larger than the host set. sigismember() returns 1 if the specified signal number is a member of the specified signal set, but it can also return -1 if an error occurs (e.g. an out of range signal number is specified). All non-zero values would cause the signal to be added, so a comparison with 1 is added to assure that only the signals which are really in the set get added to the other set. Signed-off-by: Miloš Stojanović --- linux-user/signal.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/linux-user/signal.c b/linux-user/signal.c index ae4da79..b96d508 100644 --- a/linux-user/signal.c +++ b/linux-user/signal.c @@ -149,7 +149,7 @@ static void host_to_target_sigset_internal(target_sigset_t *d, int i; target_sigemptyset(d); for (i = 1; i <= TARGET_NSIG; i++) { - if (sigismember(s, i)) { + if (sigismember(s, i) == 1) { target_sigaddset(d, host_to_target_signal(i)); } } @@ -171,7 +171,7 @@ static void target_to_host_sigset_internal(sigset_t *d, int i; sigemptyset(d); for (i = 1; i <= TARGET_NSIG; i++) { - if (target_sigismember(s, i)) { + if (target_sigismember(s, i) == 1) { sigaddset(d, target_to_host_signal(i)); } }