|
|
218e99 |
From 1826fdaaacd0d6898bb3bd64935edd520dd95428 Mon Sep 17 00:00:00 2001
|
|
|
218e99 |
From: Fam Zheng <famz@redhat.com>
|
|
|
218e99 |
Date: Tue, 6 Aug 2013 15:44:48 +0800
|
|
|
218e99 |
Subject: [PATCH 02/13] vmdk: use unsigned values for on disk header fields
|
|
|
218e99 |
|
|
|
218e99 |
Message-id: <1377573001-27070-3-git-send-email-famz@redhat.com>
|
|
|
218e99 |
Patchwork-id: 53782
|
|
|
218e99 |
O-Subject: [RHEL-7 qemu-kvm PATCH 02/13] vmdk: use unsigned values for on disk
|
|
|
218e99 |
header fields
|
|
|
218e99 |
Bugzilla: 995866
|
|
|
218e99 |
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
218e99 |
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
|
|
|
218e99 |
RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
|
|
|
218e99 |
|
|
|
218e99 |
The size and offset fields are all non-negative values, use uint64_t for
|
|
|
218e99 |
them to avoid getting negative in memory value by int overflow.
|
|
|
218e99 |
|
|
|
218e99 |
Signed-off-by: Fam Zheng <famz@redhat.com>
|
|
|
218e99 |
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
|
|
|
218e99 |
(cherry picked from commit e98768d43799cd3f00b358bfbe455fdae793d3e8)
|
|
|
218e99 |
Signed-off-by: Fam Zheng <famz@redhat.com>
|
|
|
218e99 |
---
|
|
|
218e99 |
block/vmdk.c | 24 ++++++++++++------------
|
|
|
218e99 |
1 files changed, 12 insertions(+), 12 deletions(-)
|
|
|
218e99 |
|
|
|
218e99 |
diff --git a/block/vmdk.c b/block/vmdk.c
|
|
|
218e99 |
index e85f4ea..78ea480 100644
|
|
|
218e99 |
--- a/block/vmdk.c
|
|
|
218e99 |
+++ b/block/vmdk.c
|
|
|
218e99 |
@@ -67,14 +67,14 @@ typedef struct {
|
|
|
218e99 |
typedef struct {
|
|
|
218e99 |
uint32_t version;
|
|
|
218e99 |
uint32_t flags;
|
|
|
218e99 |
- int64_t capacity;
|
|
|
218e99 |
- int64_t granularity;
|
|
|
218e99 |
- int64_t desc_offset;
|
|
|
218e99 |
- int64_t desc_size;
|
|
|
218e99 |
- int32_t num_gtes_per_gte;
|
|
|
218e99 |
- int64_t rgd_offset;
|
|
|
218e99 |
- int64_t gd_offset;
|
|
|
218e99 |
- int64_t grain_offset;
|
|
|
218e99 |
+ uint64_t capacity;
|
|
|
218e99 |
+ uint64_t granularity;
|
|
|
218e99 |
+ uint64_t desc_offset;
|
|
|
218e99 |
+ uint64_t desc_size;
|
|
|
218e99 |
+ uint32_t num_gtes_per_gte;
|
|
|
218e99 |
+ uint64_t rgd_offset;
|
|
|
218e99 |
+ uint64_t gd_offset;
|
|
|
218e99 |
+ uint64_t grain_offset;
|
|
|
218e99 |
char filler[1];
|
|
|
218e99 |
char check_bytes[4];
|
|
|
218e99 |
uint16_t compressAlgorithm;
|
|
|
218e99 |
@@ -109,7 +109,7 @@ typedef struct VmdkExtent {
|
|
|
218e99 |
|
|
|
218e99 |
typedef struct BDRVVmdkState {
|
|
|
218e99 |
CoMutex lock;
|
|
|
218e99 |
- int desc_offset;
|
|
|
218e99 |
+ uint64_t desc_offset;
|
|
|
218e99 |
bool cid_updated;
|
|
|
218e99 |
uint32_t parent_cid;
|
|
|
218e99 |
int num_extents;
|
|
|
218e99 |
@@ -490,7 +490,7 @@ static int vmdk_open_vmdk3(BlockDriverState *bs,
|
|
|
218e99 |
}
|
|
|
218e99 |
|
|
|
218e99 |
static int vmdk_open_desc_file(BlockDriverState *bs, int flags,
|
|
|
218e99 |
- int64_t desc_offset);
|
|
|
218e99 |
+ uint64_t desc_offset);
|
|
|
218e99 |
|
|
|
218e99 |
static int vmdk_open_vmdk4(BlockDriverState *bs,
|
|
|
218e99 |
BlockDriverState *file,
|
|
|
218e99 |
@@ -508,7 +508,7 @@ static int vmdk_open_vmdk4(BlockDriverState *bs,
|
|
|
218e99 |
return ret;
|
|
|
218e99 |
}
|
|
|
218e99 |
if (header.capacity == 0) {
|
|
|
218e99 |
- int64_t desc_offset = le64_to_cpu(header.desc_offset);
|
|
|
218e99 |
+ uint64_t desc_offset = le64_to_cpu(header.desc_offset);
|
|
|
218e99 |
if (desc_offset) {
|
|
|
218e99 |
return vmdk_open_desc_file(bs, flags, desc_offset << 9);
|
|
|
218e99 |
}
|
|
|
218e99 |
@@ -728,7 +728,7 @@ next_line:
|
|
|
218e99 |
}
|
|
|
218e99 |
|
|
|
218e99 |
static int vmdk_open_desc_file(BlockDriverState *bs, int flags,
|
|
|
218e99 |
- int64_t desc_offset)
|
|
|
218e99 |
+ uint64_t desc_offset)
|
|
|
218e99 |
{
|
|
|
218e99 |
int ret;
|
|
|
218e99 |
char *buf = NULL;
|
|
|
218e99 |
--
|
|
|
218e99 |
1.7.1
|
|
|
218e99 |
|