]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
The last sparse block info must reach the end of file.
authorMichihiro NAKAJIMA <ggcueroad@gmail.com>
Thu, 11 Feb 2010 05:50:35 +0000 (00:50 -0500)
committerMichihiro NAKAJIMA <ggcueroad@gmail.com>
Thu, 11 Feb 2010 05:50:35 +0000 (00:50 -0500)
SVN-Revision: 1894

libarchive/archive_write_set_format_pax.c

index 892295467430e5f281d657115d2c8c433f276bb9..420a018f6fa06993294efde64419e2e53445c601 100644 (file)
@@ -497,6 +497,21 @@ archive_write_pax_header(struct archive_write *a,
                sparse_count = archive_entry_sparse_reset(entry_main);
        else
                sparse_count = 0;
+       if (sparse_count) {
+               int64_t offset, length, last_offset = 0;
+               /* Get the last entry of sparse block. */
+               while (archive_entry_sparse_next(
+                   entry_main, &offset, &length) == ARCHIVE_OK)
+                       last_offset = offset + length;
+
+               /* If the last sparse block does not reach the end of file,
+                * We have to add a empty sparse block as the last entry to
+                * manage storing file data. */
+               if (last_offset < archive_entry_size(entry_main))
+                       archive_entry_sparse_add_entry(entry_main,
+                           archive_entry_size(entry_main), 0);
+               sparse_count = archive_entry_sparse_reset(entry_main);
+       }
 
        /*
         * First, check the name fields and see if any of them