]> git.proxmox.com Git - mirror_qemu.git/commitdiff
dmg: fix reading of uncompressed chunks
authorChristoph Hellwig <hch@lst.de>
Fri, 7 May 2010 14:55:33 +0000 (16:55 +0200)
committerKevin Wolf <kwolf@redhat.com>
Mon, 17 May 2010 08:20:05 +0000 (10:20 +0200)
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>
block/dmg.c

index d5c1a687e443192716c3fb40d3df35d62f4abfaa..02a3d6720601aefd9c5c20f793c5432b49d18ba9 100644 (file)
@@ -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;