All of lore.kernel.org
 help / color / mirror / Atom feed
From: Fam Zheng <famz@redhat.com>
To: John Snow <jsnow@redhat.com>
Cc: kwolf@redhat.com, qemu-devel@nongnu.org, qemu-block@nongnu.org
Subject: Re: [Qemu-devel] [PATCH] qemu-img: initialize MapEntry object
Date: Thu, 4 Feb 2016 09:38:58 +0800	[thread overview]
Message-ID: <20160204013858.GA5187@ad.usersys.redhat.com> (raw)
In-Reply-To: <1454542737-14742-1-git-send-email-jsnow@redhat.com>

On Wed, 02/03 18:38, John Snow wrote:
> Commit 16b0d555 introduced an issue where we are not initializing
> has_filename for the 'next' MapEntry object, which leads to interesting
> errors in Valgrind and Clang -fsanitize=undefined both.
> 
> Zero the stack object at allocation AND make sure the utility to
> populate the fields properly marks has_filename as false if applicable.
> 
> Signed-off-by: John Snow <jsnow@redhat.com>
> ---
>  qemu-img.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/qemu-img.c b/qemu-img.c
> index f121980..5a85178 100644
> --- a/qemu-img.c
> +++ b/qemu-img.c
> @@ -2231,6 +2231,9 @@ static int get_block_status(BlockDriverState *bs, int64_t sector_num,
>      if (file && e->has_offset) {
>          e->has_filename = true;
>          e->filename = file->filename;
> +    } else {
> +        e->has_filename = false;
> +        e->filename = NULL;
>      }
>      return 0;
>  }
> @@ -2264,7 +2267,7 @@ static int img_map(int argc, char **argv)
>      BlockDriverState *bs;
>      const char *filename, *fmt, *output;
>      int64_t length;
> -    MapEntry curr = { .length = 0 }, next;
> +    MapEntry curr = { .length = 0 }, next = { .length = 0 };
>      int ret = 0;
>  
>      fmt = NULL;
> -- 
> 2.4.3
> 

Reviewed-by: Fam Zheng <famz@redhat.com>

  reply	other threads:[~2016-02-04  1:39 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-03 23:38 [Qemu-devel] [PATCH] qemu-img: initialize MapEntry object John Snow
2016-02-04  1:38 ` Fam Zheng [this message]
2016-02-04 12:43 ` Kevin Wolf
2016-02-04 15:52   ` 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=20160204013858.GA5187@ad.usersys.redhat.com \
    --to=famz@redhat.com \
    --cc=jsnow@redhat.com \
    --cc=kwolf@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 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.