Skip to content

Commit

Permalink
block: Fix nb_sectors check in bdrv_check_byte_request()
Browse files Browse the repository at this point in the history
nb_sectors is signed, check for negative values.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
  • Loading branch information
kevmw committed Apr 22, 2014
1 parent 2d03b49 commit 54db38a
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion block.c
Expand Up @@ -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;
}

Expand Down

0 comments on commit 54db38a

Please sign in to comment.