aboutsummaryrefslogtreecommitdiff
path: root/block/vhdx-log.c
diff options
context:
space:
mode:
Diffstat (limited to 'block/vhdx-log.c')
-rw-r--r--block/vhdx-log.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/block/vhdx-log.c b/block/vhdx-log.c
index 2e26fd46a5..95972230f0 100644
--- a/block/vhdx-log.c
+++ b/block/vhdx-log.c
@@ -553,7 +553,11 @@ static int vhdx_log_flush(BlockDriverState *bs, BDRVVHDXState *s,
new_file_size = desc_entries->hdr.last_file_offset;
if (new_file_size % (1024*1024)) {
/* round up to nearest 1MB boundary */
- new_file_size = ((new_file_size >> 20) + 1) << 20;
+ new_file_size = QEMU_ALIGN_UP(new_file_size, MiB);
+ if (new_file_size > INT64_MAX) {
+ ret = -EINVAL;
+ goto exit;
+ }
bdrv_truncate(bs->file, new_file_size, PREALLOC_MODE_OFF, NULL);
}
}