From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:37537) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UN97x-0000tS-Nf for qemu-devel@nongnu.org; Tue, 02 Apr 2013 17:52:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UN97w-0000Xk-P6 for qemu-devel@nongnu.org; Tue, 02 Apr 2013 17:52:25 -0400 Sender: fluxion From: Michael Roth Date: Tue, 2 Apr 2013 16:45:40 -0500 Message-Id: <1364939142-30066-36-git-send-email-mdroth@linux.vnet.ibm.com> In-Reply-To: <1364939142-30066-1-git-send-email-mdroth@linux.vnet.ibm.com> References: <1364939142-30066-1-git-send-email-mdroth@linux.vnet.ibm.com> Subject: [Qemu-devel] [PATCH 35/37] linux-user: make bogus negative iovec lengths fail EINVAL List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: qemu-stable@nongnu.org From: Peter Maydell If the guest passes us a bogus negative length for an iovec, fail EINVAL rather than proceeding blindly forward. This fixes some of the error cases tests for readv and writev in the LTP. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson Signed-off-by: Riku Voipio (cherry picked from commit dfae8e00f8ddeedcda24bd28f71d4fd2a9f988b8) Signed-off-by: Michael Roth --- linux-user/syscall.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 7bc5ba9..b682357 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -1776,7 +1776,7 @@ static struct iovec *lock_iovec(int type, abi_ulong target_addr, errno = 0; return NULL; } - if (count > IOV_MAX) { + if (count < 0 || count > IOV_MAX) { errno = EINVAL; return NULL; } -- 1.7.9.5