From: Max Reitz Date: Mon, 30 Sep 2013 06:59:28 +0000 (+0200) Subject: qcow2: Correct endianness in overlap check X-Git-Tag: qemu-xen-4.5.0-rc1~433^2~7 X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=1e242b5544a48bc43eca9c637dc91ec06bcf3a31;p=qemu-upstream-4.5-testing.git qcow2: Correct endianness in overlap check If an inactive L1 table is loaded from disk, its entries are in big endian and have to be converted to host byte order before using them. Signed-off-by: Max Reitz Reviewed-by: Kevin Wolf Signed-off-by: Stefan Hajnoczi --- diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c index d2b7064a0..364eeba0f 100644 --- a/block/qcow2-refcount.c +++ b/block/qcow2-refcount.c @@ -1733,8 +1733,8 @@ int qcow2_check_metadata_overlap(BlockDriverState *bs, int chk, int64_t offset, } for (j = 0; j < l1_sz; j++) { - if ((l1[j] & L1E_OFFSET_MASK) && - overlaps_with(l1[j] & L1E_OFFSET_MASK, s->cluster_size)) { + uint64_t l2_ofs = be64_to_cpu(l1[j]) & L1E_OFFSET_MASK; + if (l2_ofs && overlaps_with(l2_ofs, s->cluster_size)) { g_free(l1); return QCOW2_OL_INACTIVE_L2; }