qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PULL 20/31] qcow2: Catch bdrv_getlength() error


From: Kevin Wolf
Subject: [Qemu-devel] [PULL 20/31] qcow2: Catch bdrv_getlength() error
Date: Wed, 30 Apr 2014 20:23:52 +0200

From: Max Reitz <address@hidden>

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 <address@hidden>
Signed-off-by: Kevin Wolf <address@hidden>
---
 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++;
-- 
1.8.3.1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]