qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Xu Wang <cngesaint@gmail.com>
To: qemu-devel@nongnu.org
Cc: cngesaint@gmail.com, Xu Wang <cngesaint@outlook.com>
Subject: [Qemu-devel] [PATCH 2/2] Check infinite loop in img_create()
Date: Thu, 27 Jun 2013 03:38:20 -0400	[thread overview]
Message-ID: <1372318700-25103-3-git-send-email-cngesaint@gmail.com> (raw)
In-Reply-To: <1372318700-25103-1-git-send-email-cngesaint@gmail.com>

From: Xu Wang <cngesaint@outlook.com>

Signed-off-by: Xu Wang <cngesaint@outlook.com>
---
 qemu-img.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/qemu-img.c b/qemu-img.c
index 0bc265d..fe11421 100644
--- a/qemu-img.c
+++ b/qemu-img.c
@@ -415,6 +415,7 @@ static int img_create(int argc, char **argv)
     char *options = NULL;
     Error *local_err = NULL;
     bool quiet = false;
+    char backing_file[1024];
 
     for(;;) {
         c = getopt(argc, argv, "F:b:f:he6o:q");
@@ -481,6 +482,16 @@ static int img_create(int argc, char **argv)
         return print_block_option_help(filename, fmt);
     }
 
+    /* check infinite loop in backing file chain */
+    if (options) {
+        if (get_param_value(backing_file, sizeof(backing_file),
+                            "backing_file", options)) {
+            if (backing_file_loop_check(filename, fmt, true, backing_file)) {
+                return 1;
+            }
+        }
+    }
+
     bdrv_img_create(filename, fmt, base_filename, base_fmt,
                     options, img_size, BDRV_O_FLAGS, &local_err, quiet);
     if (error_is_set(&local_err)) {
-- 
1.8.1.4

  parent reply	other threads:[~2013-06-27  7:38 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-27  7:38 [Qemu-devel] [PATCH 0/2] Add infinite loop checking in img_create() Xu Wang
2013-06-27  7:38 ` [Qemu-devel] [PATCH 1/2] Refine and export infinite loop checking in collect_image_info_list() Xu Wang
2013-06-28 20:37   ` Eric Blake
2013-07-04 13:00     ` Stefan Hajnoczi
2013-07-08  7:31     ` Xu Wang
2013-06-27  7:38 ` Xu Wang [this message]
2013-06-29 14:32 ` [Qemu-devel] [PATCH 0/2] Add infinite loop checking in img_create() Andreas Färber
2013-07-04 13:01   ` Stefan Hajnoczi

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=1372318700-25103-3-git-send-email-cngesaint@gmail.com \
    --to=cngesaint@gmail.com \
    --cc=cngesaint@outlook.com \
    --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).