From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38117) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Us6n4-00076E-5C for qemu-devel@nongnu.org; Thu, 27 Jun 2013 03:38:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Us6n1-0007rj-Ca for qemu-devel@nongnu.org; Thu, 27 Jun 2013 03:38:50 -0400 Received: from mail-pa0-x22e.google.com ([2607:f8b0:400e:c03::22e]:34729) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Us6n1-0007rW-6L for qemu-devel@nongnu.org; Thu, 27 Jun 2013 03:38:47 -0400 Received: by mail-pa0-f46.google.com with SMTP id fa11so686610pad.33 for ; Thu, 27 Jun 2013 00:38:46 -0700 (PDT) From: Xu Wang Date: Thu, 27 Jun 2013 03:38:20 -0400 Message-Id: <1372318700-25103-3-git-send-email-cngesaint@gmail.com> In-Reply-To: <1372318700-25103-1-git-send-email-cngesaint@gmail.com> References: <1372318700-25103-1-git-send-email-cngesaint@gmail.com> Subject: [Qemu-devel] [PATCH 2/2] Check infinite loop in img_create() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: cngesaint@gmail.com, Xu Wang From: Xu Wang Signed-off-by: Xu Wang --- 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