From patchwork Thu Dec 2 17:46:49 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jes Sorensen X-Patchwork-Id: 74007 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 522681007D1 for ; Fri, 3 Dec 2010 04:56:05 +1100 (EST) Received: from localhost ([127.0.0.1]:34774 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PODNy-0003Pz-7d for incoming@patchwork.ozlabs.org; Thu, 02 Dec 2010 12:56:02 -0500 Received: from [140.186.70.92] (port=33271 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PODFG-00011p-0R for qemu-devel@nongnu.org; Thu, 02 Dec 2010 12:47:03 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PODFA-0001n5-Bf for qemu-devel@nongnu.org; Thu, 02 Dec 2010 12:47:01 -0500 Received: from mx1.redhat.com ([209.132.183.28]:48324) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PODFA-0001mt-4u for qemu-devel@nongnu.org; Thu, 02 Dec 2010 12:46:56 -0500 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id oB2Hktih019132 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 2 Dec 2010 12:46:55 -0500 Received: from red-feather.redhat.com (ovpn-113-61.phx2.redhat.com [10.3.113.61]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id oB2HkoIq029632; Thu, 2 Dec 2010 12:46:54 -0500 From: Jes.Sorensen@redhat.com To: kwolf@redhat.com Date: Thu, 2 Dec 2010 18:46:49 +0100 Message-Id: <1291312009-24351-4-git-send-email-Jes.Sorensen@redhat.com> In-Reply-To: <1291312009-24351-1-git-send-email-Jes.Sorensen@redhat.com> References: <1291312009-24351-1-git-send-email-Jes.Sorensen@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.25 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. Cc: qemu-devel@nongnu.org Subject: [Qemu-devel] [PATCH 3/3] Fail if detecting an unknown option X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Jes Sorensen This patch changes qemu-img to exit if an unknown option is detected, instead of trying to continue with a set of arguments which may be incorrect. Signed-off-by: Jes Sorensen --- qemu-img.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 48 insertions(+), 0 deletions(-) diff --git a/qemu-img.c b/qemu-img.c index d0dc445..f2e1c94 100644 --- a/qemu-img.c +++ b/qemu-img.c @@ -304,6 +304,12 @@ static int img_create(int argc, char **argv) flags = 0; for(;;) { c = getopt(argc, argv, "F:b:f:he6o:"); + /* + * Fail if we detect an unknown argument + */ + if (c == '?') { + return 1; + } if (c == -1) { break; } @@ -472,6 +478,12 @@ static int img_check(int argc, char **argv) fmt = NULL; for(;;) { c = getopt(argc, argv, "f:h"); + /* + * Fail if we detect an unknown argument + */ + if (c == '?') { + return 1; + } if (c == -1) { break; } @@ -550,6 +562,12 @@ static int img_commit(int argc, char **argv) fmt = NULL; for(;;) { c = getopt(argc, argv, "f:h"); + /* + * Fail if we detect an unknown argument + */ + if (c == '?') { + return 1; + } if (c == -1) { break; } @@ -688,6 +706,12 @@ static int img_convert(int argc, char **argv) flags = 0; for(;;) { c = getopt(argc, argv, "f:O:B:s:hce6o:"); + /* + * Fail if we detect an unknown argument + */ + if (c == '?') { + return 1; + } if (c == -1) { break; } @@ -1094,6 +1118,12 @@ static int img_info(int argc, char **argv) fmt = NULL; for(;;) { c = getopt(argc, argv, "f:h"); + /* + * Fail if we detect an unknown argument + */ + if (c == '?') { + return 1; + } if (c == -1) { break; } @@ -1171,6 +1201,12 @@ static int img_snapshot(int argc, char **argv) /* Parse commandline parameters */ for(;;) { c = getopt(argc, argv, "la:c:d:h"); + /* + * Fail if we detect an unknown argument + */ + if (c == '?') { + return 1; + } if (c == -1) { break; } @@ -1286,6 +1322,12 @@ static int img_rebase(int argc, char **argv) for(;;) { c = getopt(argc, argv, "uhf:F:b:"); + /* + * Fail if we detect an unknown argument + */ + if (c == '?') { + return 1; + } if (c == -1) { break; } @@ -1500,6 +1542,12 @@ static int img_resize(int argc, char **argv) fmt = NULL; for(;;) { c = getopt(argc, argv, "f:h"); + /* + * Fail if we detect an unknown argument + */ + if (c == '?') { + return 1; + } if (c == -1) { break; }