Patchwork Fix 32-bit overflow in parallels image support

login
register
mail settings
Submitter David Woodhouse
Date Nov. 7, 2009, 2:10 p.m.
Message ID <1257603001.30774.127.camel@macbook.infradead.org>
Download mbox | patch
Permalink /patch/37916/
State New
Headers show

Comments

David Woodhouse - Nov. 7, 2009, 2:10 p.m.
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>

Patch

diff --git a/block/parallels.c b/block/parallels.c
index 0b64a5c..63b6738 100644
--- a/block/parallels.c
+++ b/block/parallels.c
@@ -119,7 +119,8 @@  fail:
 static inline int seek_to_sector(BlockDriverState *bs, int64_t sector_num)
 {
     BDRVParallelsState *s = bs->opaque;
-    uint32_t index, offset, position;
+    uint32_t index, offset;
+    uint64_t position;
 
     index = sector_num / s->tracks;
     offset = sector_num % s->tracks;
@@ -128,7 +129,7 @@  static inline int seek_to_sector(BlockDriverState *bs, int64_t sector_num)
     if ((index > s->catalog_size) || (s->catalog_bitmap[index] == 0))
 	return -1;
 
-    position = (s->catalog_bitmap[index] + offset) * 512;
+    position = (uint64_t)(s->catalog_bitmap[index] + offset) * 512;
 
 //    fprintf(stderr, "sector: %llx index=%x offset=%x pointer=%x position=%x\n",
 //	sector_num, index, offset, s->catalog_bitmap[index], position);