From 54db38a47978381e23e7f6479c31a97b5d352f7e Mon Sep 17 00:00:00 2001 From: Kevin Wolf Date: Mon, 14 Apr 2014 14:47:14 +0200 Subject: [PATCH] block: Fix nb_sectors check in bdrv_check_byte_request() nb_sectors is signed, check for negative values. Signed-off-by: Kevin Wolf Reviewed-by: Max Reitz --- block.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/block.c b/block.c index 990a7542a9..3b7951eb4f 100644 --- 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; } -- GitLab