From: Max Reitz Date: Tue, 29 Apr 2014 17:03:13 +0000 (+0200) Subject: qcow2: Catch bdrv_getlength() error X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=a49139af77850d64d74f9ffe43cabe7aa4f19de0;p=qemu.git qcow2: Catch bdrv_getlength() error 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 --- diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c index d2cb6a8775..e79895d11d 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++;