From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58055) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UkCh4-00049J-Tr for qemu-devel@nongnu.org; Wed, 05 Jun 2013 08:20:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UkCgz-0004MW-H3 for qemu-devel@nongnu.org; Wed, 05 Jun 2013 08:19:58 -0400 Received: from mx1.redhat.com ([209.132.183.28]:55472) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UkCgz-0004MQ-8S for qemu-devel@nongnu.org; Wed, 05 Jun 2013 08:19:53 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r55CJqrs020563 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 5 Jun 2013 08:19:52 -0400 From: Kevin Wolf Date: Wed, 5 Jun 2013 14:19:29 +0200 Message-Id: <1370434781-28570-5-git-send-email-kwolf@redhat.com> In-Reply-To: <1370434781-28570-1-git-send-email-kwolf@redhat.com> References: <1370434781-28570-1-git-send-email-kwolf@redhat.com> Subject: [Qemu-devel] [PATCH v2 04/16] qemu-io: Handle cvtnum() errors in 'alloc' List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: kwolf@redhat.com, pbonzini@redhat.com, stefanha@redhat.com, lcapitulino@redhat.com Signed-off-by: Kevin Wolf Reviewed-by: Eric Blake --- 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; } -- 1.8.1.4