From patchwork Wed Apr 30 18:23:52 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Wolf X-Patchwork-Id: 344263 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)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 9DB551401DD for ; Thu, 1 May 2014 04:26:59 +1000 (EST) Received: from localhost ([::1]:58421 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WfZDd-0002yc-EE for incoming@patchwork.ozlabs.org; Wed, 30 Apr 2014 14:26:57 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45712) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WfZBS-0007OS-9E for qemu-devel@nongnu.org; Wed, 30 Apr 2014 14:24:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WfZBM-0003Ii-4j for qemu-devel@nongnu.org; Wed, 30 Apr 2014 14:24:42 -0400 Received: from mx1.redhat.com ([209.132.183.28]:41903) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WfZBL-0003Ib-UA for qemu-devel@nongnu.org; Wed, 30 Apr 2014 14:24:36 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s3UIOYNZ029400 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 30 Apr 2014 14:24:35 -0400 Received: from noname.redhat.com (ovpn-116-113.ams2.redhat.com [10.36.116.113]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s3UIO4is011903; Wed, 30 Apr 2014 14:24:33 -0400 From: Kevin Wolf To: qemu-devel@nongnu.org Date: Wed, 30 Apr 2014 20:23:52 +0200 Message-Id: <1398882243-14783-21-git-send-email-kwolf@redhat.com> In-Reply-To: <1398882243-14783-1-git-send-email-kwolf@redhat.com> References: <1398882243-14783-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com Subject: [Qemu-devel] [PULL 20/31] qcow2: Catch bdrv_getlength() error 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: Max Reitz The call to bdrv_getlength() from qcow2_check_refcounts() may result in an error. Check this and abort if necessary. Signed-off-by: Max Reitz Signed-off-by: Kevin Wolf --- block/qcow2-refcount.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c index d2cb6a8..e79895d 100644 --- a/block/qcow2-refcount.c +++ b/block/qcow2-refcount.c @@ -1487,6 +1487,11 @@ int qcow2_check_refcounts(BlockDriverState *bs, BdrvCheckResult *res, int ret; size = bdrv_getlength(bs->file); + if (size < 0) { + res->check_errors++; + return size; + } + nb_clusters = size_to_clusters(s, size); if (nb_clusters > INT_MAX) { res->check_errors++;