mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-04 00:03:54 -06:00
block/vpc: check that the image has not been truncated
this adds a check that a dynamic VHD file has not been accidently truncated (e.g. during transfer or upload). Signed-off-by: Peter Lieven <pl@kamp.de> Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
This commit is contained in:
parent
fefddf951b
commit
fb8fe35f63
1 changed files with 7 additions and 0 deletions
|
@ -260,6 +260,13 @@ static int vpc_open(BlockDriverState *bs, QDict *options, int flags,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (s->free_data_block_offset > bdrv_getlength(bs->file)) {
|
||||||
|
error_setg(errp, "block-vpc: free_data_block_offset points after "
|
||||||
|
"the end of file. The image has been truncated.");
|
||||||
|
ret = -EINVAL;
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
|
|
||||||
s->last_bitmap_offset = (int64_t) -1;
|
s->last_bitmap_offset = (int64_t) -1;
|
||||||
|
|
||||||
#ifdef CACHE
|
#ifdef CACHE
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue