qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH 1/3] dmg: fix reading of uncompressed chunks


From: Christoph Hellwig
Subject: [Qemu-devel] [PATCH 1/3] dmg: fix reading of uncompressed chunks
Date: Fri, 7 May 2010 16:55:33 +0200
User-agent: Mutt/1.3.28i

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 <address@hidden>

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;




reply via email to

[Prev in Thread] Current Thread [Next in Thread]