From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:41874) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UhLpL-0004LN-Ne for qemu-devel@nongnu.org; Tue, 28 May 2013 11:28:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UhLpG-0007VM-8j for qemu-devel@nongnu.org; Tue, 28 May 2013 11:28:43 -0400 Received: from mx1.redhat.com ([209.132.183.28]:50337) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UhLpG-0007VG-0r for qemu-devel@nongnu.org; Tue, 28 May 2013 11:28:38 -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 r4SFSbJT018200 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 28 May 2013 11:28:37 -0400 From: Kevin Wolf Date: Tue, 28 May 2013 17:27:24 +0200 Message-Id: <1369754856-30036-5-git-send-email-kwolf@redhat.com> In-Reply-To: <1369754856-30036-1-git-send-email-kwolf@redhat.com> References: <1369754856-30036-1-git-send-email-kwolf@redhat.com> Subject: [Qemu-devel] [PATCH 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 --- 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