qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Eric Blake <eblake@redhat.com>
To: Shwetha Mathangi Chandra Choodamani
	<saphira.brightscales@gmail.com>,
	qemu-devel@nongnu.org
Cc: kwolf@redhat.com, famz@redhat.com, stefanha@redhat.com
Subject: Re: [Qemu-devel] [PATCH v2] Fix for qemu-img info to supply FORMAT values for SPARSE extents
Date: Tue, 01 Apr 2014 17:15:10 -0600	[thread overview]
Message-ID: <533B487E.6010800@redhat.com> (raw)
In-Reply-To: <20140401214954.GA2902@smaugslair>

[-- Attachment #1: Type: text/plain, Size: 1347 bytes --]

On 04/01/2014 03:49 PM, Shwetha Mathangi Chandra Choodamani wrote:
> This patch fixes the bug in qemu-img info that wouldn't populate the extent type for default formats.
> The extent type has now been set where necessary. This is the second version in the series after inputs
> from Fam Zheng(famz@redhat.com).
> 
> Signed-off-by: Shwetha Mathangi Chandra Choodamani <saphira.brightscales@gmail.com>
> ---
>  block/vmdk.c |   53 +++++++++++++++++++++++++++++++++++++++++++++++++----
>  1 file changed, 49 insertions(+), 4 deletions(-)
> 

> +    bdrv_pread(file, sizeof(magic), buf, size);
> +    sscanf(buf, "%10s %" SCNd64 " %10s \"%511[^\n\r\"]\" %" SCNd64,
> +    access, &sectors, type, fname, &flat_offset);

Odd indentation.  Furthermore, sscanf() has undefined behavior if the
input values overflow the width of the integer variable you are parsing
into.  While you are not the first client of sscanf in the code base, I
strongly recommend that you use something that isn't vulnerable to
undefined behavior on untrusted external input, or at the VERY least,
check the sscanf() return value as well as put a %n parameter at the end
of your format string to ensure that you parsed what you thought you did.

-- 
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: 604 bytes --]

  reply	other threads:[~2014-04-01 23:15 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-04-01 21:49 [Qemu-devel] [PATCH v2] Fix for qemu-img info to supply FORMAT values for SPARSE extents Shwetha Mathangi Chandra Choodamani
2014-04-01 23:15 ` Eric Blake [this message]
2014-04-02  2:14 ` Fam Zheng

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=533B487E.6010800@redhat.com \
    --to=eblake@redhat.com \
    --cc=famz@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=saphira.brightscales@gmail.com \
    --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 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).