diff options
author | Peter Lieven <pl@kamp.de> | 2013-10-24 09:16:03 +0200 |
---|---|---|
committer | Kevin Wolf <kwolf@redhat.com> | 2013-10-24 17:34:48 +0200 |
commit | fb8fe35f63a56170cf1bf92b1991d0056385b901 (patch) | |
tree | 275c0c5760c0c9b737c0db1ef7217addf9f85bd5 /block/vpc.c | |
parent | fefddf951b6dfe51c28d41f86669bfffb68c7a15 (diff) |
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>
Diffstat (limited to 'block/vpc.c')
-rw-r--r-- | block/vpc.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/block/vpc.c b/block/vpc.c index b5dca3961e..627d11cb9b 100644 --- a/block/vpc.c +++ b/block/vpc.c @@ -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; #ifdef CACHE |