diff options
author | Fam Zheng <famz@redhat.com> | 2014-01-21 15:07:43 +0800 |
---|---|---|
committer | Kevin Wolf <kwolf@redhat.com> | 2014-01-24 14:33:00 +0100 |
commit | 34ceed81f9ca31829448276dafe3d9151d66962c (patch) | |
tree | ec261752eeef0b69139325ebfe4149435c0d7f8b /block/vmdk.c | |
parent | 46bae927134468d27f5e2508c3ced67ff58fa45b (diff) | |
download | qemu-34ceed81f9ca31829448276dafe3d9151d66962c.zip |
vmdk: Check for overhead when opening
Report an error if file size is even smaller than metadata.
Signed-off-by: Fam Zheng <famz@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'block/vmdk.c')
-rw-r--r-- | block/vmdk.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/block/vmdk.c b/block/vmdk.c index 599a928545..74c44bd5fb 100644 --- a/block/vmdk.c +++ b/block/vmdk.c @@ -640,6 +640,13 @@ static int vmdk_open_vmdk4(BlockDriverState *bs, if (le32_to_cpu(header.flags) & VMDK4_FLAG_RGD) { l1_backup_offset = le64_to_cpu(header.rgd_offset) << 9; } + if (bdrv_getlength(file) < + le64_to_cpu(header.grain_offset) * BDRV_SECTOR_SIZE) { + error_report("File truncated, expecting at least %lld bytes", + le64_to_cpu(header.grain_offset) * BDRV_SECTOR_SIZE); + return -EINVAL; + } + ret = vmdk_add_extent(bs, file, false, le64_to_cpu(header.capacity), le64_to_cpu(header.gd_offset) << 9, |