From patchwork Fri Nov 2 03:32:47 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: liguang X-Patchwork-Id: 196469 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 0CFC52C0347 for ; Fri, 2 Nov 2012 14:33:53 +1100 (EST) Received: from localhost ([::1]:52853 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TU811-0002Xs-Rj for incoming@patchwork.ozlabs.org; Thu, 01 Nov 2012 23:33:51 -0400 Received: from eggs.gnu.org ([208.118.235.92]:37930) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TU80u-0002Vr-UC for qemu-devel@nongnu.org; Thu, 01 Nov 2012 23:33:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TU80t-0006p3-Id for qemu-devel@nongnu.org; Thu, 01 Nov 2012 23:33:44 -0400 Received: from [222.73.24.84] (port=46878 helo=song.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TU80t-0006ot-7O for qemu-devel@nongnu.org; Thu, 01 Nov 2012 23:33:43 -0400 X-IronPort-AV: E=Sophos;i="4.80,697,1344182400"; d="scan'208";a="6121132" Received: from unknown (HELO tang.cn.fujitsu.com) ([10.167.250.3]) by song.cn.fujitsu.com with ESMTP; 02 Nov 2012 11:32:06 +0800 Received: from fnstmail02.fnst.cn.fujitsu.com (tang.cn.fujitsu.com [127.0.0.1]) by tang.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id qA23XfUk002303 for ; Fri, 2 Nov 2012 11:33:41 +0800 Received: from liguang.fnst.cn.fujitsu.com ([10.167.225.128]) by fnstmail02.fnst.cn.fujitsu.com (Lotus Domino Release 8.5.3) with ESMTP id 2012110211325545-926200 ; Fri, 2 Nov 2012 11:32:55 +0800 From: liguang To: qemu-devel@nongnu.org Date: Fri, 2 Nov 2012 11:32:47 +0800 Message-Id: <1351827167-21171-1-git-send-email-lig.fnst@cn.fujitsu.com> X-Mailer: git-send-email 1.7.2.5 X-MIMETrack: Itemize by SMTP Server on mailserver/fnst(Release 8.5.3|September 15, 2011) at 2012/11/02 11:32:55, Serialize by Router on mailserver/fnst(Release 8.5.3|September 15, 2011) at 2012/11/02 11:32:55, Serialize complete at 2012/11/02 11:32:55 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 222.73.24.84 Cc: liguang Subject: [Qemu-devel] [PATCH] correct error message qemu-img reported 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 qemu-img will complain when qcow or qcow2 size overflow for 64 bits, report the right message in this condition. Signed-off-by: liguang --- qemu-img.c | 16 +++++++++------- 1 files changed, 9 insertions(+), 7 deletions(-) diff --git a/qemu-img.c b/qemu-img.c index f17f187..2a45427 100644 --- a/qemu-img.c +++ b/qemu-img.c @@ -343,15 +343,17 @@ static int img_create(int argc, char **argv) /* Get image size, if specified */ if (optind < argc) { - int64_t sval; + int64_t sval = 0; char *end; sval = strtosz_suffix(argv[optind++], &end, STRTOSZ_DEFSUFFIX_B); - if (sval < 0 || *end) { - error_report("Invalid image size specified! You may use k, M, G or " - "T suffixes for "); - error_report("kilobytes, megabytes, gigabytes and terabytes."); - ret = -1; - goto out; + if (sval < 0) + error_report("image size is too large!\n"); + if (*end) { + error_report("Invalid image size specified! You may use k, M, G or " + "T suffixes for "); + error_report("kilobytes, megabytes, gigabytes and terabytes."); + ret = -1; + goto out; } img_size = (uint64_t)sval; }