From patchwork Wed Oct 28 20:40:46 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 537562 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 D9B69141355 for ; Thu, 29 Oct 2015 07:41:25 +1100 (AEDT) Received: from localhost ([::1]:40644 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZrXX9-0002g7-JA for incoming@patchwork.ozlabs.org; Wed, 28 Oct 2015 16:41:23 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47315) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZrXWg-0001qY-5n for qemu-devel@nongnu.org; Wed, 28 Oct 2015 16:40:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZrXWd-0004Pf-OY for qemu-devel@nongnu.org; Wed, 28 Oct 2015 16:40:54 -0400 Received: from smtp4-g21.free.fr ([2a01:e0c:1:1599::13]:37959) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZrXWd-0004PH-JJ for qemu-devel@nongnu.org; Wed, 28 Oct 2015 16:40:51 -0400 Received: from Quad.localdomain (unknown [78.238.229.36]) by smtp4-g21.free.fr (Postfix) with ESMTPS id EAFB14C8029; Wed, 28 Oct 2015 21:40:50 +0100 (CET) From: Laurent Vivier To: qemu-devel@nongnu.org Date: Wed, 28 Oct 2015 21:40:46 +0100 Message-Id: <1446064846-12529-6-git-send-email-laurent@vivier.eu> X-Mailer: git-send-email 2.4.3 In-Reply-To: <1446064846-12529-1-git-send-email-laurent@vivier.eu> References: <1446064846-12529-1-git-send-email-laurent@vivier.eu> X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a01:e0c:1:1599::13 Cc: peter.maydell@linaro.org, riku.voipio@iki.fi, Laurent Vivier Subject: [Qemu-devel] [PATCH v3 5/5] linux-user: check fd is >= 0 in fd_trans_host_to_target_data/fd_trans_host_to_target_addr 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 Signed-off-by: Laurent Vivier --- linux-user/syscall.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 22b28a4..eb45e72 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -309,7 +309,7 @@ static unsigned int target_fd_max; static TargetFdDataFunc fd_trans_host_to_target_data(int fd) { - if (fd < target_fd_max && target_fd_trans[fd]) { + if (fd >= 0 && fd < target_fd_max && target_fd_trans[fd]) { return target_fd_trans[fd]->host_to_target_data; } return NULL; @@ -317,7 +317,7 @@ static TargetFdDataFunc fd_trans_host_to_target_data(int fd) static TargetFdAddrFunc fd_trans_target_to_host_addr(int fd) { - if (fd < target_fd_max && target_fd_trans[fd]) { + if (fd >= 0 && fd < target_fd_max && target_fd_trans[fd]) { return target_fd_trans[fd]->target_to_host_addr; } return NULL;