From mboxrd@z Thu Jan 1 00:00:00 1970 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 From: Stefan Hajnoczi 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> Subject: [Qemu-devel] [PULL 05/26] 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: Kevin Wolf , Anthony Liguori , Stefan Hajnoczi 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; } -- 1.8.1.4