]> rtime.felk.cvut.cz Git - lisovros/qemu_apohw.git/commitdiff
block: Limit size to INT_MAX in bdrv_check_byte_request()
authorKevin Wolf <kwolf@redhat.com>
Mon, 14 Apr 2014 12:48:16 +0000 (14:48 +0200)
committerKevin Wolf <kwolf@redhat.com>
Tue, 22 Apr 2014 09:57:02 +0000 (11:57 +0200)
Commit 8f4754ed intended to protect against integer overflow bugs in
block drivers by making sure that a single request that is passed to
drivers is no longer than INT_MAX bytes.

However, meanwhile there are some callers that don't use that code path
any more but call bdrv_check_byte_request() directy, so let's add a
check there as well.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
block.c

diff --git a/block.c b/block.c
index 3b7951eb4f887b0a9c6f3a950528a40ab16db0d7..5a0b4216554dac79932adcecf0a369b424a0da03 100644 (file)
--- a/block.c
+++ b/block.c
@@ -2581,6 +2581,10 @@ static int bdrv_check_byte_request(BlockDriverState *bs, int64_t offset,
 {
     int64_t len;
 
+    if (size > INT_MAX) {
+        return -EIO;
+    }
+
     if (!bdrv_is_inserted(bs))
         return -ENOMEDIUM;