Skip to contentSkip to conversation

qcow2: Fix potential qemu-img check crash on 32 bit hosts

PATCH In review Kevin Wolf 2 participants 2 messages Dec 1, 2015 Block layer

lore
Share & tools
lore

Kevin Wolf

author
#0 lore raw

PATCH 1/1 qcow2: Fix potential qemu-img check crash on 32 bit hosts

This crash was caught with qemu-iotests test case 138.

Commit b6d36de already fixed a few 32 bit truncation bugs that could cause qemu-img check to allocate too little memory and consequently it would segfault. On 32 bit hosts, there is one more place that needs to be fixed because size_t was involved in the calculation and is a 32 bit type there.

---
 block/qcow2-refcount.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
block/qcow2-refcount.c +1 -1
index 6e0e5bd..820f412 100644
@@ -1244,7 +1244,7 @@ fail:
 /* refcount checking functions */
 
 
-static size_t refcount_array_byte_size(BDRVQcow2State *s, uint64_t entries)
+static uint64_t refcount_array_byte_size(BDRVQcow2State *s, uint64_t entries)
 {
     /* This assertion holds because there is no way we can address more than
      * 2^(64 - 9) clusters at once (with cluster size 512 = 2^9, and because
Signature · 1 line
1.8.3.1
Tested-by on v1 1/1
#1 lore raw
Quoted 11 lines · Kevin Wolf

This crash was caught with qemu-iotests test case 138.

Commit b6d36de already fixed a few 32 bit truncation bugs that could cause qemu-img check to allocate too little memory and consequently it would segfault. On 32 bit hosts, there is one more place that needs to be fixed because size_t was involved in the calculation and is a 32 bit type there.

Quoted 19 lines
---
 block/qcow2-refcount.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
block/qcow2-refcount.c +1 -1
index 6e0e5bd..820f412 100644
@@ -1244,7 +1244,7 @@ fail:
 /* refcount checking functions */
 
 
-static size_t refcount_array_byte_size(BDRVQcow2State *s, uint64_t entries)
+static uint64_t refcount_array_byte_size(BDRVQcow2State *s, uint64_t entries)
 {
     /* This assertion holds because there is no way we can address more than
      * 2^(64 - 9) clusters at once (with cluster size 512 = 2^9, and because
Signature · 1 line
1.8.3.1