yeahuh / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone

Blame SOURCES/vmdk-refuse-to-open-higher-version-than-supported.patch

9ae3a8
From 06989fa543551f16e41b0218e10125df31ccbc0b Mon Sep 17 00:00:00 2001
9ae3a8
From: Miroslav Rezanina <mrezanin@redhat.com>
9ae3a8
Date: Wed, 31 Jul 2013 09:54:55 +0200
9ae3a8
Subject: vmdk: refuse to open higher version than supported
9ae3a8
9ae3a8
Message-id: <1374654509-5535-4-git-send-email-famz@redhat.com>
9ae3a8
Patchwork-id: 52675
9ae3a8
O-Subject: [RHEL-7 qemu-kvm PATCH 3/5] vmdk: refuse to open higher version than supported
9ae3a8
Bugzilla: 836675
9ae3a8
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
9ae3a8
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
9ae3a8
RH-Acked-by: Jeffrey Cody <jcody@redhat.com>
9ae3a8
RH-Acked-by: Michal Novotny <minovotn@redhat.com>
9ae3a8
9ae3a8
Refuse to open higher version for safety.
9ae3a8
9ae3a8
Although we try to be compatible with published VMDK spec, VMware has
9ae3a8
newer version from ESXi 5.1 exported OVF/OVA, which we have no knowledge
9ae3a8
what's changed in it. And it is very likely to have more new versions in
9ae3a8
the future, so it's not safe to open them blindly.
9ae3a8
9ae3a8
Signed-off-by: Fam Zheng <famz@redhat.com>
9ae3a8
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
9ae3a8
(cherry picked from commit 96c51eb5e46af2312b33f745ad72acb20e799aea)
9ae3a8
Signed-off-by: Fam Zheng <famz@redhat.com>
9ae3a8
9ae3a8
diff --git a/block/vmdk.c b/block/vmdk.c
9ae3a8
index 65ae011..975e1d4 100644
9ae3a8
--- a/block/vmdk.c
9ae3a8
+++ b/block/vmdk.c
9ae3a8
@@ -561,6 +561,15 @@ static int vmdk_open_vmdk4(BlockDriverState *bs,
9ae3a8
         header = footer.header;
9ae3a8
     }
9ae3a8
 
9ae3a8
+    if (le32_to_cpu(header.version) >= 3) {
9ae3a8
+        char buf[64];
9ae3a8
+        snprintf(buf, sizeof(buf), "VMDK version %d",
9ae3a8
+                 le32_to_cpu(header.version));
9ae3a8
+        qerror_report(QERR_UNKNOWN_BLOCK_FORMAT_FEATURE,
9ae3a8
+                bs->device_name, "vmdk", buf);
9ae3a8
+        return -ENOTSUP;
9ae3a8
+    }
9ae3a8
+
9ae3a8
     l1_entry_sectors = le32_to_cpu(header.num_gtes_per_gte)
9ae3a8
                         * le64_to_cpu(header.granularity);
9ae3a8
     if (l1_entry_sectors == 0) {