OSDN Git Service

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 990a754..3b7951e 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;
     }