aboutsummaryrefslogtreecommitdiff
path: root/block.c
diff options
context:
space:
mode:
Diffstat (limited to 'block.c')
-rw-r--r--block.c17
1 files changed, 16 insertions, 1 deletions
diff --git a/block.c b/block.c
index eb16fb48c6..8f177504d4 100644
--- a/block.c
+++ b/block.c
@@ -962,6 +962,11 @@ int refresh_total_sectors(BlockDriverState *bs, int64_t hint)
}
bs->total_sectors = hint;
+
+ if (bs->total_sectors * BDRV_SECTOR_SIZE > BDRV_MAX_LENGTH) {
+ return -EFBIG;
+ }
+
return 0;
}
@@ -5535,6 +5540,7 @@ void bdrv_get_backing_filename(BlockDriverState *bs,
int bdrv_get_info(BlockDriverState *bs, BlockDriverInfo *bdi)
{
+ int ret;
BlockDriver *drv = bs->drv;
/* if bs->drv == NULL, bs is closed, so there's nothing to do here */
if (!drv) {
@@ -5548,7 +5554,16 @@ int bdrv_get_info(BlockDriverState *bs, BlockDriverInfo *bdi)
return -ENOTSUP;
}
memset(bdi, 0, sizeof(*bdi));
- return drv->bdrv_get_info(bs, bdi);
+ ret = drv->bdrv_get_info(bs, bdi);
+ if (ret < 0) {
+ return ret;
+ }
+
+ if (bdi->cluster_size > BDRV_MAX_ALIGNMENT) {
+ return -EINVAL;
+ }
+
+ return 0;
}
ImageInfoSpecific *bdrv_get_specific_info(BlockDriverState *bs,