[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH] block/vpc: check that the image has not been trunca
From: |
Peter Lieven |
Subject: |
[Qemu-devel] [PATCH] block/vpc: check that the image has not been truncated |
Date: |
Tue, 22 Oct 2013 08:43:25 +0200 |
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 <address@hidden>
---
block/vpc.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/block/vpc.c b/block/vpc.c
index 1acc1d4..921364e 100644
--- a/block/vpc.c
+++ b/block/vpc.c
@@ -269,6 +269,13 @@ static int vpc_open(BlockDriverState *bs, QDict *options,
int flags,
}
}
+ if (s->free_data_block_offset > bdrv_getlength(bs->file)) {
+ ret = -EINVAL;
+ fprintf(stderr, "block-vpc: free_data_block_offset points after"
+ "the end of file. the image has been
truncated.\n");
+ goto fail;
+ }
+
s->last_bitmap_offset = (int64_t) -1;
#ifdef CACHE
--
1.7.9.5
- [Qemu-devel] [PATCH] block/vpc: check that the image has not been truncated,
Peter Lieven <=