All of lore.kernel.org
 help / color / mirror / Atom feed
From: Max Reitz <mreitz@redhat.com>
To: Hu Tao <hutao@cn.fujitsu.com>, qemu-devel@nongnu.org
Cc: Kevin Wolf <kwolf@redhat.com>, Stefan Hajnoczi <stefanha@redhat.com>
Subject: Re: [Qemu-devel] [PATCH v1 2/3] qcow2: fix offset overflow
Date: Sun, 19 Jan 2014 17:12:08 +0100	[thread overview]
Message-ID: <52DBF958.7090107@redhat.com> (raw)
In-Reply-To: <b35a6f5ed4492fe971dfb03218e9b5b9abdd72f5.1388381026.git.hutao@cn.fujitsu.com>

On 30.12.2013 06:29, Hu Tao wrote:
> When cluster size is big enough it can lead offset overflow
> in qcow2_alloc_clusters_at(). This patch fixes it.
>
> Signed-off-by: Hu Tao <hutao@cn.fujitsu.com>
> ---
>   block/qcow2-refcount.c | 7 ++++++-
>   1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c
> index c974abe..b3ebb7f 100644
> --- a/block/qcow2-refcount.c
> +++ b/block/qcow2-refcount.c
> @@ -676,7 +676,12 @@ int qcow2_alloc_clusters_at(BlockDriverState *bs, uint64_t offset,
>       BDRVQcowState *s = bs->opaque;
>       uint64_t cluster_index;
>       uint64_t old_free_cluster_index;
> -    int i, refcount, ret;
> +    uint64_t i;
> +    int refcount, ret;
> +
> +    if (nb_clusters <= 0) {
> +        return 0;

I think I'd rather return -EINVAL here.

> +    }
>   
>       /* Check how many clusters there are free */
>       cluster_index = offset >> s->cluster_bits;

  parent reply	other threads:[~2014-01-19 16:10 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-30  5:29 [Qemu-devel] [PATCH v1 0/3] qcow2: fix bugs when cluster size is larger than the default value Hu Tao
2013-12-30  5:29 ` [Qemu-devel] [PATCH v1 1/3] qcow2: remove n_start and n_end of qcow2_alloc_cluster_offset() Hu Tao
2014-01-19 16:08   ` Max Reitz
2013-12-30  5:29 ` [Qemu-devel] [PATCH v1 2/3] qcow2: fix offset overflow Hu Tao
2014-01-06  8:35   ` Hu Tao
2014-01-19 16:12   ` Max Reitz [this message]
2014-01-20 15:14     ` Kevin Wolf
2013-12-30  5:29 ` [Qemu-devel] [PATCH v1 3/3] qcow2: check for NULL l2meta Hu Tao
2014-01-19 16:18   ` Max Reitz
2014-01-20  3:04     ` Hu Tao
2014-01-20 15:17       ` Kevin Wolf
2014-01-21  3:33         ` Hu Tao
2014-01-21  6:02           ` Hu Tao
2014-01-21 11:04             ` Kevin Wolf
2014-01-22  3:49               ` Hu Tao
2014-01-13 10:26 ` [Qemu-devel] [PATCH v1 0/3] qcow2: fix bugs when cluster size is larger than the default value Hu Tao

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=52DBF958.7090107@redhat.com \
    --to=mreitz@redhat.com \
    --cc=hutao@cn.fujitsu.com \
    --cc=kwolf@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.