vmdk: byteswap VMDK4Header.desc_offset field
authorStefan Hajnoczi <stefanha@redhat.com>
Mon, 10 Jun 2013 09:07:33 +0000 (11:07 +0200)
committerKevin Wolf <kwolf@redhat.com>
Mon, 17 Jun 2013 15:47:59 +0000 (17:47 +0200)
Remember to byteswap VMDK4Header.desc_offset on big-endian machines.

Cc: qemu-stable@nongnu.org
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
block/vmdk.c

index 608daaf93093ffbb6e99006613dde9fbf48e20f2..ee50a737c140733be4018b7b1a235821e33f3a05 100644 (file)
@@ -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) {