* [Qemu-devel] [PATCH] block/vpc: check that the image has not been truncated
@ 2013-10-22 6:43 Peter Lieven
2013-10-22 6:59 ` Eric Blake
0 siblings, 1 reply; 3+ messages in thread
From: Peter Lieven @ 2013-10-22 6:43 UTC (permalink / raw)
To: qemu-devel; +Cc: kwolf, aliguori, jcody, Peter Lieven, stefanha, pbonzini
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>
---
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
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [PATCH] block/vpc: check that the image has not been truncated
2013-10-22 6:43 [Qemu-devel] [PATCH] block/vpc: check that the image has not been truncated Peter Lieven
@ 2013-10-22 6:59 ` Eric Blake
2013-10-22 7:26 ` Peter Lieven
0 siblings, 1 reply; 3+ messages in thread
From: Eric Blake @ 2013-10-22 6:59 UTC (permalink / raw)
To: Peter Lieven, qemu-devel; +Cc: kwolf, pbonzini, aliguori, jcody, stefanha
[-- Attachment #1: Type: text/plain, Size: 1023 bytes --]
On 10/22/2013 07:43 AM, Peter Lieven wrote:
> 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>
> ---
> 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");
Why fprintf() instead of using the errp argument?
Also, s/afterthe/after the/; s/file\. the/file. The/
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 621 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [PATCH] block/vpc: check that the image has not been truncated
2013-10-22 6:59 ` Eric Blake
@ 2013-10-22 7:26 ` Peter Lieven
0 siblings, 0 replies; 3+ messages in thread
From: Peter Lieven @ 2013-10-22 7:26 UTC (permalink / raw)
To: Eric Blake, qemu-devel; +Cc: kwolf, pbonzini, aliguori, jcody, stefanha
On 22.10.2013 08:59, Eric Blake wrote:
> On 10/22/2013 07:43 AM, Peter Lieven wrote:
>> 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>
>> ---
>> 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");
> Why fprintf() instead of using the errp argument?
wasn't aware. a few lines earlier fprintf(stderr, ...) was used.
if the others are otherwise happy with the patch I will send a v2.
Peter
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2013-10-22 7:26 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-10-22 6:43 [Qemu-devel] [PATCH] block/vpc: check that the image has not been truncated Peter Lieven
2013-10-22 6:59 ` Eric Blake
2013-10-22 7:26 ` Peter Lieven
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).