From patchwork Mon Jun 10 09:07:33 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Hajnoczi X-Patchwork-Id: 250198 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id BE4AD2C02A9 for ; Mon, 10 Jun 2013 19:08:14 +1000 (EST) Received: from localhost ([::1]:57416 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Uly5E-0001fb-8u for incoming@patchwork.ozlabs.org; Mon, 10 Jun 2013 05:08:12 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52568) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Uly4u-0001fD-4w for qemu-devel@nongnu.org; Mon, 10 Jun 2013 05:07:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Uly4n-0004FJ-LU for qemu-devel@nongnu.org; Mon, 10 Jun 2013 05:07:52 -0400 Received: from mx1.redhat.com ([209.132.183.28]:24457) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Uly4n-0004F6-Du; Mon, 10 Jun 2013 05:07:45 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r5A97ho4001466 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 10 Jun 2013 05:07:43 -0400 Received: from localhost (ovpn-112-37.ams2.redhat.com [10.36.112.37]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r5A97g8q007692; Mon, 10 Jun 2013 05:07:42 -0400 From: Stefan Hajnoczi To: Date: Mon, 10 Jun 2013 11:07:33 +0200 Message-Id: <1370855253-7842-1-git-send-email-stefanha@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , Fam Zheng , qemu-stable@nongnu.org, Stefan Hajnoczi Subject: [Qemu-devel] [PATCH] vmdk: byteswap VMDK4Header.desc_offset field X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Remember to byteswap VMDK4Header.desc_offset on big-endian machines. Cc: qemu-stable@nongnu.org Signed-off-by: Stefan Hajnoczi --- block/vmdk.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/block/vmdk.c b/block/vmdk.c index 608daaf..ee50a73 100644 --- a/block/vmdk.c +++ b/block/vmdk.c @@ -507,8 +507,11 @@ static int vmdk_open_vmdk4(BlockDriverState *bs, if (ret < 0) { return ret; } - if (header.capacity == 0 && header.desc_offset) { - return vmdk_open_desc_file(bs, flags, header.desc_offset << 9); + if (header.capacity == 0) { + int64_t desc_offset = le64_to_cpu(header.desc_offset); + if (desc_offset) { + return vmdk_open_desc_file(bs, flags, desc_offset << 9); + } } if (le64_to_cpu(header.gd_offset) == VMDK4_GD_AT_END) {