]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
Get a sprase info in GNU PAX formart "1.0" before the process of
authorMichihiro NAKAJIMA <ggcueroad@gmail.com>
Fri, 5 Feb 2010 04:26:39 +0000 (23:26 -0500)
committerMichihiro NAKAJIMA <ggcueroad@gmail.com>
Fri, 5 Feb 2010 04:26:39 +0000 (23:26 -0500)
reading file data so that we reliably get the sparse info with
archive_entry_sparse_*() functions.

SVN-Revision: 1870

libarchive/archive_read_support_format_tar.c

index aa2169b2dbcc3735e5a03c4777a6d27919e56e0b..8d71fae183f50d49a7e57eee0caeaa8c9573c9a9 100644 (file)
@@ -454,24 +454,6 @@ archive_read_format_tar_read_data(struct archive_read *a,
 
        tar = (struct tar *)(a->format->data);
 
-       if (tar->sparse_gnu_pending) {
-               if (tar->sparse_gnu_major == 1 && tar->sparse_gnu_minor == 0) {
-                       tar->sparse_gnu_pending = 0;
-                       /* Read initial sparse map. */
-                       bytes_read = gnu_sparse_10_read(a, tar);
-                       tar->entry_bytes_remaining -= bytes_read;
-                       if (bytes_read < 0)
-                               return (bytes_read);
-               } else {
-                       *size = 0;
-                       *offset = 0;
-                       archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
-                           "Unrecognized GNU sparse file format");
-                       return (ARCHIVE_WARN);
-               }
-               tar->sparse_gnu_pending = 0;
-       }
-
        /* Remove exhausted entries from sparse list. */
        while (tar->sparse_list != NULL &&
            tar->sparse_list->remaining == 0) {
@@ -661,8 +643,28 @@ tar_read_header(struct archive_read *a, struct tar *tar,
        }
        --tar->header_recursion_depth;
        /* We return warnings or success as-is.  Anything else is fatal. */
-       if (err == ARCHIVE_WARN || err == ARCHIVE_OK)
+       if (err == ARCHIVE_WARN || err == ARCHIVE_OK) {
+               if (tar->sparse_gnu_pending) {
+                       if (tar->sparse_gnu_major == 1 &&
+                           tar->sparse_gnu_minor == 0) {
+                               ssize_t bytes_read;
+
+                               tar->sparse_gnu_pending = 0;
+                               /* Read initial sparse map. */
+                               bytes_read = gnu_sparse_10_read(a, tar);
+                               tar->entry_bytes_remaining -= bytes_read;
+                               if (bytes_read < 0)
+                                       return (bytes_read);
+                       } else {
+                               archive_set_error(&a->archive,
+                                   ARCHIVE_ERRNO_MISC,
+                                   "Unrecognized GNU sparse file format");
+                               return (ARCHIVE_WARN);
+                       }
+                       tar->sparse_gnu_pending = 0;
+               }
                return (err);
+       }
        if (err == ARCHIVE_EOF)
                /* EOF when recursively reading a header is bad. */
                archive_set_error(&a->archive, EINVAL, "Damaged tar archive");