From mboxrd@z Thu Jan 1 00:00:00 1970 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 From: Laurent Vivier Date: Wed, 28 Oct 2015 21:40:46 +0100 Message-Id: <1446064846-12529-6-git-send-email-laurent@vivier.eu> In-Reply-To: <1446064846-12529-1-git-send-email-laurent@vivier.eu> References: <1446064846-12529-1-git-send-email-laurent@vivier.eu> 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 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org, riku.voipio@iki.fi, Laurent Vivier 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; -- 2.4.3