From 981daae137fd383944e72dbea8f147499eb9add4 Mon Sep 17 00:00:00 2001 From: Max Reitz <mreitz@redhat.com> Date: Sat, 13 Jun 2015 16:21:56 +0200 Subject: [PATCH 02/42] qcow2: Catch bdrv_getlength() error Message-id: <1434212556-3927-3-git-send-email-mreitz@redhat.com> Patchwork-id: 66021 O-Subject: [RHEL-7.2 qemu-kvm PATCH 02/42] qcow2: Catch bdrv_getlength() error Bugzilla: 1129893 RH-Acked-by: Jeffrey Cody <jcody@redhat.com> RH-Acked-by: Fam Zheng <famz@redhat.com> RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com> BZ: 1129893 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 <mreitz@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com> (cherry picked from commit a49139af77850d64d74f9ffe43cabe7aa4f19de0) Signed-off-by: Max Reitz <mreitz@redhat.com> Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com> --- block/qcow2-refcount.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c index 429b01c..4f86923 100644 --- a/block/qcow2-refcount.c +++ b/block/qcow2-refcount.c @@ -1478,6 +1478,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++; -- 1.8.3.1