From mboxrd@z Thu Jan 1 00:00:00 1970 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) From: riku.voipio@linaro.org Date: Mon, 11 Jan 2016 16:16:11 +0200 Message-Id: <861d72cd28b5793fc367c46b7821a5372b66e3f4.1452521686.git.riku.voipio@linaro.org> In-Reply-To: References: 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 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Laurent Vivier 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; -- 2.6.4