From: Christoph Hellwig Date: Fri, 7 May 2010 14:55:33 +0000 (+0200) Subject: dmg: fix reading of uncompressed chunks X-Git-Tag: v0.13.0-rc0~517^2~6 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=cd02a24b6112da50816a8021d97a2b26038f7190;p=thirdparty%2Fqemu.git 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 Signed-off-by: Kevin Wolf --- diff --git a/block/dmg.c b/block/dmg.c index d5c1a687e44..02a3d672060 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;