From: Jeff Cody <jcody@redhat.com>
To: Eric Blake <eblake@redhat.com>
Cc: qemu-devel@nongnu.org, kwolf@redhat.com, armbru@redhat.com,
qemu-block@nongnu.org, Max Reitz <mreitz@redhat.com>
Subject: Re: [Qemu-devel] [Qemu-block] [PATCH 1/4] vpc: Check failure of bdrv_getlength()
Date: Mon, 7 Aug 2017 19:32:12 -0400 [thread overview]
Message-ID: <20170807233212.GL22129@localhost.localdomain> (raw)
In-Reply-To: <20170807203007.19033-2-eblake@redhat.com>
On Mon, Aug 07, 2017 at 03:30:04PM -0500, Eric Blake wrote:
> vpc_open() was checking for bdrv_getlength() failure in one, but
> not the other, location.
>
> Reported-by: Markus Armbruster <armbru@redhat.com>
> Signed-off-by: Eric Blake <eblake@redhat.com>
> ---
> block/vpc.c | 9 ++++++++-
> 1 file changed, 8 insertions(+), 1 deletion(-)
>
> diff --git a/block/vpc.c b/block/vpc.c
> index 574879ba7c..468d10ec1c 100644
> --- a/block/vpc.c
> +++ b/block/vpc.c
> @@ -219,6 +219,7 @@ static int vpc_open(BlockDriverState *bs, QDict *options, int flags,
> uint64_t pagetable_size;
> int disk_type = VHD_DYNAMIC;
> int ret;
> + int64_t bs_size;
>
> bs->file = bdrv_open_child(NULL, options, "file", bs, &child_file,
> false, errp);
> @@ -411,7 +412,13 @@ static int vpc_open(BlockDriverState *bs, QDict *options, int flags,
> }
> }
>
> - if (s->free_data_block_offset > bdrv_getlength(bs->file->bs)) {
> + bs_size = bdrv_getlength(bs->file->bs);
> + if (bs_size < 0) {
> + error_setg_errno(errp, -bs_size, "unable to learn image size");
> + ret = bs_size;
> + goto fail;
> + }
> + if (s->free_data_block_offset > bs_size) {
> error_setg(errp, "block-vpc: free_data_block_offset points after "
> "the end of file. The image has been truncated.");
> ret = -EINVAL;
> --
> 2.13.4
>
>
Reviewed-by: Jeff Cody <jcody@redhat.com>
next prev parent reply other threads:[~2017-08-07 23:32 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-07 20:30 [Qemu-devel] [PATCH for-2.10 0/4] More blk_getlength() fixes Eric Blake
2017-08-07 20:30 ` [Qemu-devel] [PATCH 1/4] vpc: Check failure of bdrv_getlength() Eric Blake
2017-08-07 20:43 ` Philippe Mathieu-Daudé
2017-08-07 23:32 ` Jeff Cody [this message]
2017-08-08 8:30 ` Kevin Wolf
2017-08-07 20:30 ` [Qemu-devel] [PATCH 2/4] qcow: Check failure of bdrv_getlength() and bdrv_truncate() Eric Blake
2017-08-07 20:51 ` Philippe Mathieu-Daudé
2017-08-07 23:33 ` [Qemu-devel] [Qemu-block] " Jeff Cody
2017-08-07 23:35 ` Jeff Cody
2017-08-08 8:28 ` [Qemu-devel] " Kevin Wolf
2017-08-08 14:16 ` Eric Blake
2017-08-07 20:30 ` [Qemu-devel] [PATCH 3/4] qcow2: Drop debugging dump_refcounts() Eric Blake
2017-08-07 20:44 ` Philippe Mathieu-Daudé
2017-08-07 23:33 ` [Qemu-devel] [Qemu-block] " Jeff Cody
2017-08-08 8:32 ` [Qemu-devel] " Kevin Wolf
2017-08-07 20:30 ` [Qemu-devel] [PATCH 4/4] qcow2: Check failure of bdrv_getlength() Eric Blake
2017-08-07 20:47 ` Philippe Mathieu-Daudé
2017-08-07 23:34 ` [Qemu-devel] [Qemu-block] " Jeff Cody
2017-08-08 8:32 ` [Qemu-devel] " Kevin Wolf
2017-08-07 22:58 ` [Qemu-devel] [Qemu-block] [PATCH for-2.10 0/4] More blk_getlength() fixes John Snow
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170807233212.GL22129@localhost.localdomain \
--to=jcody@redhat.com \
--cc=armbru@redhat.com \
--cc=eblake@redhat.com \
--cc=kwolf@redhat.com \
--cc=mreitz@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).