]> xenbits.xensource.com Git - qemu-xen.git/commitdiff
block: Fix nb_sectors check in bdrv_check_byte_request()
authorKevin Wolf <kwolf@redhat.com>
Mon, 14 Apr 2014 12:47:14 +0000 (14:47 +0200)
committerKevin Wolf <kwolf@redhat.com>
Tue, 22 Apr 2014 09:57:02 +0000 (11:57 +0200)
nb_sectors is signed, check for negative values.

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 990a7542a9495ade8237e7b13a68216cc6300bd2..3b7951eb4f887b0a9c6f3a950528a40ab16db0d7 100644 (file)
--- a/block.c
+++ b/block.c
@@ -2601,7 +2601,7 @@ static int bdrv_check_byte_request(BlockDriverState *bs, int64_t offset,
 static int bdrv_check_request(BlockDriverState *bs, int64_t sector_num,
                               int nb_sectors)
 {
-    if (nb_sectors > INT_MAX / BDRV_SECTOR_SIZE) {
+    if (nb_sectors < 0 || nb_sectors > INT_MAX / BDRV_SECTOR_SIZE) {
         return -EIO;
     }