From patchwork Mon Jan 11 14:16:11 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Riku Voipio X-Patchwork-Id: 565898 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 907CA1402ED for ; Tue, 12 Jan 2016 01:24:23 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b=OxQCzgI+; dkim-atps=neutral Received: from localhost ([::1]:54536 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aIdOP-0002FC-EI for incoming@patchwork.ozlabs.org; Mon, 11 Jan 2016 09:24:21 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52595) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aIdGt-0004cS-IF for qemu-devel@nongnu.org; Mon, 11 Jan 2016 09:16:41 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aIdGs-0002AG-MJ for qemu-devel@nongnu.org; Mon, 11 Jan 2016 09:16:35 -0500 Received: from mail-lf0-x22c.google.com ([2a00:1450:4010:c07::22c]:33498) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aIdGs-0002AB-Eo for qemu-devel@nongnu.org; Mon, 11 Jan 2016 09:16:34 -0500 Received: by mail-lf0-x22c.google.com with SMTP id m198so66847600lfm.0 for ; Mon, 11 Jan 2016 06:16:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=4aKrgroEFJFVidQgm8KWzjm/sAkvA7mg0UP77CWacZI=; b=OxQCzgI+waJdfB7V78cka5ROlzAEiPO7C4wZU2xNq/PMu3ycSGkweVswLt/9w0v9ap UnL/GUMeS2WIq9D1epIRspS0yHIbz09y5ZqKH5MZjKjASnbgHBBe20AOZN5vA8Htl40/ 206+HD50HjOfXSQtVFmfpCXlljfO/0Gi4XbC4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=4aKrgroEFJFVidQgm8KWzjm/sAkvA7mg0UP77CWacZI=; b=ioiGDRrtHUcE+RA8EyF2l1GoqBZc2WXxijSFLvgLOGPpoEl0fAQGRi7Ldcpgnlz6+G ivug5j2GGgARcblEXRYw2hHmz8Dbuw6NI0F3xQRpn28+b4Z+cflQf+Xb9otmNk+S+8KV uf0Tzt0AgWY/Nara+uPzqEL1fTccbE4HK+uYVMSUZqJk29SGMVANiu/uubbCOAdV/ioI MkP1aeSWwH1hxkPlfc0OzEY34Z2ySVpNoDVEm0y6zPwdD77MwrwtAAn5SL2xhtlTym7d dgzM3oksZywl1qF3W634VOkJv1W+iG/Uuwzvt3kXFg2LjQymihWrG5+C4cSwKXeRHLzM S5dA== X-Gm-Message-State: ALoCoQk/UZmzoDysGkGfDudROxWdPsn0bhldkthdMYb+oDGQ344tgW3VaG09dIlwcB2if/ZEUbuXzmM2rz/7jr2peWFr9xLdvg== X-Received: by 10.25.81.133 with SMTP id f127mr8356482lfb.141.1452521793925; Mon, 11 Jan 2016 06:16:33 -0800 (PST) Received: from localhost.localdomain (91-157-175-207.elisa-laajakaista.fi. [91.157.175.207]) by smtp.gmail.com with ESMTPSA id 130sm16806735lff.31.2016.01.11.06.16.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 11 Jan 2016 06:16:32 -0800 (PST) From: riku.voipio@linaro.org To: qemu-devel@nongnu.org Date: Mon, 11 Jan 2016 16:16:11 +0200 Message-Id: <861d72cd28b5793fc367c46b7821a5372b66e3f4.1452521686.git.riku.voipio@linaro.org> X-Mailer: git-send-email 2.6.4 In-Reply-To: References: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a00:1450:4010:c07::22c Cc: Laurent Vivier Subject: [Qemu-devel] [PULL 09/17] 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 From: Laurent Vivier Signed-off-by: Laurent Vivier Signed-off-by: Riku Voipio --- 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 94d64fa..ff20ea7 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;