From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57748) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VQXSG-0004UQ-5o for qemu-devel@nongnu.org; Mon, 30 Sep 2013 02:59:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VQXSA-0006g0-71 for qemu-devel@nongnu.org; Mon, 30 Sep 2013 02:59:40 -0400 Received: from mx1.redhat.com ([209.132.183.28]:31602) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VQXS9-0006fs-W5 for qemu-devel@nongnu.org; Mon, 30 Sep 2013 02:59:34 -0400 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r8U6xWbu028147 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 30 Sep 2013 02:59:32 -0400 From: Max Reitz Date: Mon, 30 Sep 2013 08:59:28 +0200 Message-Id: <1380524368-3283-1-git-send-email-mreitz@redhat.com> Subject: [Qemu-devel] [PATCH] qcow2: Correct endianness in overlap check List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Kevin Wolf , Stefan Hajnoczi , Max Reitz 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 --- block/qcow2-refcount.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c index d2b7064..364eeba 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; } -- 1.8.3.1