]> code.ossystems Code Review - openembedded-core.git/commitdiff
filemap: check if dest is written for every block
authorEd Bartosh <ed.bartosh@linux.intel.com>
Tue, 13 Jun 2017 11:22:04 +0000 (14:22 +0300)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Wed, 14 Jun 2017 09:18:21 +0000 (10:18 +0100)
If lenght parameter is provided to sparse_copy call
it's mandatory to check if the output file is fully
written after reading unmapped block from input file.

If it's not done then sparse_copy can write more data
than specified length.

Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
scripts/lib/wic/filemap.py

index 8719f443c5a0b70278ea92a3c62521492e168f23..764dbbe588c23b70e74700197668065a17305d9e 100644 (file)
@@ -563,6 +563,13 @@ def sparse_copy(src_fname, dst_fname, skip=0, seek=0,
             start = skip
 
         fmap._f_image.seek(start, os.SEEK_SET)
+
+        written += start - skip - written
+        if length and written >= length:
+            dst_file.seek(seek + length, os.SEEK_SET)
+            dst_file.close()
+            return
+
         dst_file.seek(seek + start - skip, os.SEEK_SET)
 
         chunk_size = 1024 * 1024