From mboxrd@z Thu Jan 1 00:00:00 1970 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 Message-ID: <20100507145533.GA14245@lst.de> References: <20100507145519.GA14157@lst.de> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20100507145519.GA14157@lst.de> Subject: [Qemu-devel] [PATCH 1/3] dmg: fix reading of uncompressed chunks List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@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;