diff options
author | Blue Swirl <blauwirbel@gmail.com> | 2009-12-25 19:27:18 +0000 |
---|---|---|
committer | Blue Swirl <blauwirbel@gmail.com> | 2009-12-25 19:27:18 +0000 |
commit | ecbe1576b3287e7907b524901063a8117f544e61 (patch) | |
tree | dba6cf743ded3b0724081c3ac0db4fc64efb08e8 /block | |
parent | 114cdfa908520ccc624fc8e5409252dc6e980f8a (diff) |
block/bochs: improve format checking
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
Diffstat (limited to 'block')
-rw-r--r-- | block/bochs.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/block/bochs.c b/block/bochs.c index f6a18f2bcb..34892582ef 100644 --- a/block/bochs.c +++ b/block/bochs.c @@ -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; } |