qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Deepak Kathayat <deepak.mk17@gmail.com>
To: qemu-devel@nongnu.org
Cc: qemu-trivial@nongnu.org, Deepak Kathayat <deepak.mk17@gmail.com>,
	stefanha@redhat.com
Subject: [Qemu-devel] [PATCH] qcow2.c: Check if backing file name length is valid
Date: Wed, 19 Mar 2014 16:19:33 +0800	[thread overview]
Message-ID: <1395217173-20902-1-git-send-email-deepak.mk17@gmail.com> (raw)


Signed-off-by: Deepak Kathayat <deepak.mk17@gmail.com>
---
The len variable is a signed integer whereas the backing file name
 length in the image header is unsigned. Therefore, it may
 overflow. Furthermore, backing file name length cannot be
 zero. These two cases must be handled explicitly.
 block/qcow2.c |    5 +++++
 1 file changed, 5 insertions(+)

diff --git a/block/qcow2.c b/block/qcow2.c
index 945c9d6..7b6f65c 100644
--- a/block/qcow2.c
+++ b/block/qcow2.c
@@ -625,6 +625,11 @@ static int qcow2_open(BlockDriverState *bs, QDict *options, int flags,
     /* read the backing file name */
     if (header.backing_file_offset != 0) {
         len = header.backing_file_size;
+        if (len <= 0) {
+            error_setg(errp, "Invalid backing file name length: %d", len);
+            ret = -EINVAL;
+            goto fail;
+        }
         if (len > 1023) {
             len = 1023;
         }
-- 
1.7.9.5

                 reply	other threads:[~2014-03-19  8:20 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=1395217173-20902-1-git-send-email-deepak.mk17@gmail.com \
    --to=deepak.mk17@gmail.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-trivial@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 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).