From patchwork Fri Jun 7 11:58:24 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Hajnoczi X-Patchwork-Id: 249717 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 5D99C2C0095 for ; Fri, 7 Jun 2013 23:14:40 +1000 (EST) Received: from localhost ([::1]:40736 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UkvMC-0003Wn-J5 for incoming@patchwork.ozlabs.org; Fri, 07 Jun 2013 08:01:24 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57200) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UkvJw-0000o2-TP for qemu-devel@nongnu.org; Fri, 07 Jun 2013 07:59:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UkvJt-0004Ee-DC for qemu-devel@nongnu.org; Fri, 07 Jun 2013 07:59:04 -0400 Received: from mx1.redhat.com ([209.132.183.28]:10208) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UkvJt-0004EL-5d for qemu-devel@nongnu.org; Fri, 07 Jun 2013 07:59:01 -0400 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r57Bx0na021824 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 7 Jun 2013 07:59:00 -0400 Received: from localhost (ovpn-112-30.ams2.redhat.com [10.36.112.30]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id r57BwxZR001244; Fri, 7 Jun 2013 07:58:59 -0400 From: Stefan Hajnoczi To: Date: Fri, 7 Jun 2013 13:58:24 +0200 Message-Id: <1370606325-10680-6-git-send-email-stefanha@redhat.com> In-Reply-To: <1370606325-10680-1-git-send-email-stefanha@redhat.com> References: <1370606325-10680-1-git-send-email-stefanha@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , Anthony Liguori , Stefan Hajnoczi Subject: [Qemu-devel] [PULL 05/26] qemu-io: Handle cvtnum() errors in 'alloc' X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Kevin Wolf Signed-off-by: Kevin Wolf Reviewed-by: Eric Blake Signed-off-by: Stefan Hajnoczi --- qemu-io.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/qemu-io.c b/qemu-io.c index 8a719a8..b4f56fc 100644 --- a/qemu-io.c +++ b/qemu-io.c @@ -1596,7 +1596,10 @@ static int alloc_f(int argc, char **argv) int ret; offset = cvtnum(argv[1]); - if (offset & 0x1ff) { + if (offset < 0) { + printf("non-numeric offset argument -- %s\n", argv[1]); + return 0; + } else if (offset & 0x1ff) { printf("offset %" PRId64 " is not sector aligned\n", offset); return 0; @@ -1604,6 +1607,10 @@ static int alloc_f(int argc, char **argv) if (argc == 3) { nb_sectors = cvtnum(argv[2]); + if (nb_sectors < 0) { + printf("non-numeric length argument -- %s\n", argv[2]); + return 0; + } } else { nb_sectors = 1; }