]> git.proxmox.com Git - mirror_qemu.git/commitdiff
block/bochs: improve format checking
authorBlue Swirl <blauwirbel@gmail.com>
Fri, 25 Dec 2009 19:27:18 +0000 (19:27 +0000)
committerBlue Swirl <blauwirbel@gmail.com>
Fri, 25 Dec 2009 19:27:18 +0000 (19:27 +0000)
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
block/bochs.c

index f6a18f2bcbd99f5b0d522ed31e6f3b5c102fd07e..34892582ef18237829e5a9cd39af7e1650d098ac 100644 (file)
@@ -146,7 +146,9 @@ static int bochs_open(BlockDriverState *bs, const char *filename, int flags)
       bs->total_sectors = le64_to_cpu(bochs.extra.redolog.disk) / 512;
     }
 
-    lseek(s->fd, le32_to_cpu(bochs.header), SEEK_SET);
+    if (lseek(s->fd, le32_to_cpu(bochs.header), SEEK_SET) == (off_t)-1) {
+        goto fail;
+    }
 
     s->catalog_size = le32_to_cpu(bochs.extra.redolog.catalog);
     s->catalog_bitmap = qemu_malloc(s->catalog_size * 4);
@@ -197,7 +199,10 @@ static inline int seek_to_sector(BlockDriverState *bs, int64_t sector_num)
 //     bitmap_offset, block_offset);
 
     // read in bitmap for current extent
-    lseek(s->fd, bitmap_offset + (extent_offset / 8), SEEK_SET);
+    if (lseek(s->fd, bitmap_offset + (extent_offset / 8), SEEK_SET) ==
+        (off_t)-1) {
+        return -1;
+    }
 
     if (read(s->fd, &bitmap_entry, 1) != 1)
         return -1;
@@ -209,7 +214,9 @@ static inline int seek_to_sector(BlockDriverState *bs, int64_t sector_num)
        return -1; // not allocated
     }
 
-    lseek(s->fd, block_offset, SEEK_SET);
+    if (lseek(s->fd, block_offset, SEEK_SET) == (off_t)-1) {
+        return -1;
+    }
 
     return 0;
 }