Skip to contentSkip to conversation

vmdk: Fix integer overflow in offset calculation

PATCH Superseded Fam Zheng 1 participant 2 messages Sep 22, 2014 Block layer

v3 of 5 Superseded Latest is v5 →

lore
Share & tools
lore

Fam Zheng

author
#0 lore raw

PATCH v3 1/1 vmdk: Fix integer overflow in offset calculation

This fixes the bug introduced by commit c6ac36e (vmdk: Optimize cluster allocation).

$ ~/build/master/qemu-io /stor/vm/arch.vmdk -c 'write 2G 1k'
write failed: Invalid argument

---
v3: A new case 105 instead of embedding in 005. (Max)

---
 block/vmdk.c               |  2 +-
 tests/qemu-iotests/105     | 70 ++++++++++++++++++++++++++++++++++++++++++++++
 tests/qemu-iotests/105.out | 21 ++++++++++++++
 3 files changed, 92 insertions(+), 1 deletion(-)
 create mode 100755 tests/qemu-iotests/105
 create mode 100644 tests/qemu-iotests/105.out
block/vmdk.c +1 -1
index afdea1a..4ae6c75 100644
@@ -1113,7 +1113,7 @@ static int get_cluster_offset(BlockDriverState *bs,
     uint32_t min_count, *l2_table;
     bool zeroed = false;
     int64_t ret;
-    int32_t cluster_sector;
+    int64_t cluster_sector;
 
     if (m_data) {
         m_data->valid = 0;
tests/qemu-iotests/105 new file +70 -0

70 lines not on this page · raw message

tests/qemu-iotests/105.out new file +21 -0
new file mode 100644
index 0000000..de47061
@@ -0,0 +1,21 @@
+QA output created by 105
+
+creating large image
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=17592186044416
+
+small read
+read 4096/4096 bytes at offset 1024
+4 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+
+small write
+wrote 4096/4096 bytes at offset 8192
+4 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+
+small read at high offset
+read 4096/4096 bytes at offset 4398046511104
+4 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+
+small write at high offset
+wrote 4096/4096 bytes at offset 4398046511104
+4 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+*** done
Signature · 1 line
1.9.3
author
#1 lore raw
Quoted 1 line · Fam Zheng

+# Copyright (C) 1014 Red Hat, Inc.

Oops! Resending...

Fam