aboutsummaryrefslogtreecommitdiff
path: root/block/dmg.c
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2010-05-07 16:55:33 +0200
committerKevin Wolf <kwolf@redhat.com>2010-05-17 10:20:05 +0200
commitcd02a24b6112da50816a8021d97a2b26038f7190 (patch)
tree107c3a1890f2333d63df662a9bd3cd11a26440b5 /block/dmg.c
parentdede4188cc817a039154ed2ecd7f3285f6b94056 (diff)
dmg: fix reading of uncompressed chunks
When dmg_read_chunk encounters an uncompressed chunk it currently calls read without any previous adjustment of the file postion. This seems very wrong, and the "reference" implementation in dmg2img does a search to the same offset as done in the various compression cases, so do the same here. Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'block/dmg.c')
-rw-r--r--block/dmg.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/block/dmg.c b/block/dmg.c
index d5c1a687e4..02a3d67206 100644
--- a/block/dmg.c
+++ b/block/dmg.c
@@ -239,7 +239,8 @@ static inline int dmg_read_chunk(BDRVDMGState *s,int sector_num)
return -1;
break; }
case 1: /* copy */
- ret = read(s->fd, s->uncompressed_chunk, s->lengths[chunk]);
+ ret = pread(s->fd, s->uncompressed_chunk, s->lengths[chunk],
+ s->offsets[chunk]);
if (ret != s->lengths[chunk])
return -1;
break;