From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=41355 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OCyQU-0000d0-CJ for qemu-devel@nongnu.org; Fri, 14 May 2010 13:11:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OCyQP-0001w8-TI for qemu-devel@nongnu.org; Fri, 14 May 2010 13:11:53 -0400 Received: from mx1.redhat.com ([209.132.183.28]:45674) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OCyQP-0001vm-K1 for qemu-devel@nongnu.org; Fri, 14 May 2010 13:11:49 -0400 From: Kevin Wolf Date: Fri, 14 May 2010 19:10:49 +0200 Message-Id: <1273857055-26715-16-git-send-email-kwolf@redhat.com> In-Reply-To: <1273857055-26715-1-git-send-email-kwolf@redhat.com> References: <1273857055-26715-1-git-send-email-kwolf@redhat.com> Subject: [Qemu-devel] [PATCH 15/21] dmg: fix reading of uncompressed chunks List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: anthony@codemonkey.ws Cc: kwolf@redhat.com, qemu-devel@nongnu.org From: Christoph Hellwig 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 --- block/dmg.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-) diff --git a/block/dmg.c b/block/dmg.c index d5c1a68..02a3d67 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; -- 1.6.6.1