summaryrefslogtreecommitdiff
path: root/block.c
diff options
context:
space:
mode:
authorFam Zheng <famz@redhat.com>2014-11-10 15:07:44 +0800
committerStefan Hajnoczi <stefanha@redhat.com>2014-11-14 09:20:35 +0000
commitf3a9cfddaec127078ac1898de6b063db8ac3bb48 (patch)
treee8830cf5e066f3d602a8efc7e91a85a8e25b3f0b /block.c
parent107f0d4677e126b073d9b606788d2c126c520416 (diff)
downloadqemu-f3a9cfddaec127078ac1898de6b063db8ac3bb48.tar.gz
qemu-f3a9cfddaec127078ac1898de6b063db8ac3bb48.tar.bz2
qemu-f3a9cfddaec127078ac1898de6b063db8ac3bb48.zip
block: Fix max nb_sectors in bdrv_make_zero
In bdrv_rw_co we report -EINVAL for nb_sectors > INT_MAX / BDRV_SECTOR_SIZE, so a caller shouldn't exceed it. Signed-off-by: Fam Zheng <famz@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> Message-id: 1415603264-21497-1-git-send-email-famz@redhat.com Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Diffstat (limited to 'block.c')
-rw-r--r--block.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/block.c b/block.c
index c612826c5c..a612594db5 100644
--- a/block.c
+++ b/block.c
@@ -2790,8 +2790,8 @@ int bdrv_make_zero(BlockDriverState *bs, BdrvRequestFlags flags)
if (nb_sectors <= 0) {
return 0;
}
- if (nb_sectors > INT_MAX) {
- nb_sectors = INT_MAX;
+ if (nb_sectors > INT_MAX / BDRV_SECTOR_SIZE) {
+ nb_sectors = INT_MAX / BDRV_SECTOR_SIZE;
}
ret = bdrv_get_block_status(bs, sector_num, nb_sectors, &n);
if (ret < 0) {