]> git.proxmox.com Git - qemu.git/commitdiff
linux-user: make bogus negative iovec lengths fail EINVAL
authorPeter Maydell <peter.maydell@linaro.org>
Fri, 8 Feb 2013 07:58:41 +0000 (07:58 +0000)
committerRiku Voipio <riku.voipio@linaro.org>
Mon, 11 Mar 2013 12:34:05 +0000 (14:34 +0200)
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 <peter.maydell@linaro.org>
Reviewed-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
linux-user/syscall.c

index 17294468407fc612671568c622f242c87952439d..bab9ab58a0f1217606cb5acc19a64353f29fdac1 100644 (file)
@@ -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;
     }