05bba0
From 981daae137fd383944e72dbea8f147499eb9add4 Mon Sep 17 00:00:00 2001
05bba0
From: Max Reitz <mreitz@redhat.com>
05bba0
Date: Sat, 13 Jun 2015 16:21:56 +0200
05bba0
Subject: [PATCH 02/42] qcow2: Catch bdrv_getlength() error
05bba0
05bba0
Message-id: <1434212556-3927-3-git-send-email-mreitz@redhat.com>
05bba0
Patchwork-id: 66021
05bba0
O-Subject: [RHEL-7.2 qemu-kvm PATCH 02/42] qcow2: Catch bdrv_getlength() error
05bba0
Bugzilla: 1129893
05bba0
RH-Acked-by: Jeffrey Cody <jcody@redhat.com>
05bba0
RH-Acked-by: Fam Zheng <famz@redhat.com>
05bba0
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
05bba0
05bba0
BZ: 1129893
05bba0
05bba0
The call to bdrv_getlength() from qcow2_check_refcounts() may result in
05bba0
an error. Check this and abort if necessary.
05bba0
05bba0
Signed-off-by: Max Reitz <mreitz@redhat.com>
05bba0
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
05bba0
(cherry picked from commit a49139af77850d64d74f9ffe43cabe7aa4f19de0)
05bba0
05bba0
Signed-off-by: Max Reitz <mreitz@redhat.com>
05bba0
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
05bba0
---
05bba0
 block/qcow2-refcount.c | 5 +++++
05bba0
 1 file changed, 5 insertions(+)
05bba0
05bba0
diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c
05bba0
index 429b01c..4f86923 100644
05bba0
--- a/block/qcow2-refcount.c
05bba0
+++ b/block/qcow2-refcount.c
05bba0
@@ -1478,6 +1478,11 @@ int qcow2_check_refcounts(BlockDriverState *bs, BdrvCheckResult *res,
05bba0
     int ret;
05bba0
 
05bba0
     size = bdrv_getlength(bs->file);
05bba0
+    if (size < 0) {
05bba0
+        res->check_errors++;
05bba0
+        return size;
05bba0
+    }
05bba0
+
05bba0
     nb_clusters = size_to_clusters(s, size);
05bba0
     if (nb_clusters > INT_MAX) {
05bba0
         res->check_errors++;
05bba0
-- 
05bba0
1.8.3.1
05bba0