From patchwork Fri May 7 14:55:33 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 51926 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 89329B7D40 for ; Sat, 8 May 2010 01:23:36 +1000 (EST) Received: from localhost ([127.0.0.1]:60207 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OAP0M-0001UH-Rp for incoming@patchwork.ozlabs.org; Fri, 07 May 2010 10:58:18 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1OAOxp-00088b-2u for qemu-devel@nongnu.org; Fri, 07 May 2010 10:55:41 -0400 Received: from [140.186.70.92] (port=50013 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OAOxj-00082f-T8 for qemu-devel@nongnu.org; Fri, 07 May 2010 10:55:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OAOxi-0003Yy-An for qemu-devel@nongnu.org; Fri, 07 May 2010 10:55:35 -0400 Received: from verein.lst.de ([213.95.11.210]:45511) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OAOxh-0003Yk-UF for qemu-devel@nongnu.org; Fri, 07 May 2010 10:55:34 -0400 Received: from verein.lst.de (localhost [127.0.0.1]) by verein.lst.de (8.12.3/8.12.3/Debian-7.1) with ESMTP id o47EtXWY014274 (version=TLSv1/SSLv3 cipher=EDH-RSA-DES-CBC3-SHA bits=168 verify=NO) for ; Fri, 7 May 2010 16:55:33 +0200 Received: (from hch@localhost) by verein.lst.de (8.12.3/8.12.3/Debian-7.2) id o47EtXqi014273 for qemu-devel@nongnu.org; Fri, 7 May 2010 16:55:33 +0200 Date: Fri, 7 May 2010 16:55:33 +0200 From: Christoph Hellwig To: qemu-devel@nongnu.org Message-ID: <20100507145533.GA14245@lst.de> References: <20100507145519.GA14157@lst.de> Mime-Version: 1.0 Content-Disposition: inline In-Reply-To: <20100507145519.GA14157@lst.de> User-Agent: Mutt/1.3.28i X-Scanned-By: MIMEDefang 2.39 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) Subject: [Qemu-devel] [PATCH 1/3] dmg: fix reading of uncompressed chunks X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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 Index: qemu-kevin/block/dmg.c =================================================================== --- qemu-kevin.orig/block/dmg.c 2010-05-03 13:15:34.112253995 +0200 +++ qemu-kevin/block/dmg.c 2010-05-03 13:17:40.696287171 +0200 @@ -239,7 +239,8 @@ static inline int dmg_read_chunk(BDRVDMG 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;