qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH] allow reading variable size vmdk descriptor fil


From: Kevin Wolf
Subject: Re: [Qemu-devel] [PATCH] allow reading variable size vmdk descriptor files
Date: Wed, 12 Jun 2013 12:30:27 +0200
User-agent: Mutt/1.5.21 (2010-09-15)

Am 12.06.2013 um 10:04 hat Evgeny Budilovsky geschrieben:
> The hard-coded 2k buffer on the stack won't allow reading big descriptor
> files which can be generated when storing big images (For example 500G
> vmdk splitted to 2G chunks).
> 
> Signed-off-by: Evgeny Budilovsky <address@hidden>
> ---
>  block/vmdk.c |   28 +++++++++++++++++++++-------
>  1 file changed, 21 insertions(+), 7 deletions(-)
> 
> diff --git a/block/vmdk.c b/block/vmdk.c
> index 608daaf..1bc944b 100644
> --- a/block/vmdk.c
> +++ b/block/vmdk.c
> @@ -719,27 +719,41 @@ static int vmdk_open_desc_file(BlockDriverState *bs, 
> int flags,
>                                 int64_t desc_offset)
>  {
>      int ret;
> -    char buf[2048];
> +    char *buf = NULL;
>      char ct[128];
>      BDRVVmdkState *s = bs->opaque;
> +    int64_t size;
> 
> -    ret = bdrv_pread(bs->file, desc_offset, buf, sizeof(buf));
> +    size = bdrv_get_allocated_file_size(bs);
> +    if (size < 0) {
> +        return -EINVAL;
> +    }
> +
> +    buf = g_malloc0(size+1);

This is an unbounded allocation. Not sure if this is a good idea. Can we
restrict the maximum size to something reasonably small, like a megabyte?

Kevin



reply via email to

[Prev in Thread] Current Thread [Next in Thread]