summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorcperciva <cperciva@FreeBSD.org>2007-01-03 21:47:35 +0000
committercperciva <cperciva@FreeBSD.org>2007-01-03 21:47:35 +0000
commitac26dc2c91a8a093586c11cd739db04c72cce6cd (patch)
tree9a5f19c6238d4864c405f60fa87c3acc67709134 /lib
parent269e2dc4928188503ec9fd04ee00cb8405ba6446 (diff)
downloadFreeBSD-src-ac26dc2c91a8a093586c11cd739db04c72cce6cd.zip
FreeBSD-src-ac26dc2c91a8a093586c11cd739db04c72cce6cd.tar.gz
Rewrite and simplify archive_read_format_tar_skip. Compression-layer skip
functions are required to skip the requested distance, so we can avoid lots of bookkeeping which would otherwise be necessary. Reviewed by: kientzle MFC after: 1 week
Diffstat (limited to 'lib')
-rw-r--r--lib/libarchive/archive_read_support_format_tar.c34
1 files changed, 16 insertions, 18 deletions
diff --git a/lib/libarchive/archive_read_support_format_tar.c b/lib/libarchive/archive_read_support_format_tar.c
index 5ad9f1c..b645f7e 100644
--- a/lib/libarchive/archive_read_support_format_tar.c
+++ b/lib/libarchive/archive_read_support_format_tar.c
@@ -556,30 +556,28 @@ archive_read_format_tar_skip(struct archive *a)
r = archive_read_format_tar_read_data(a, &b, &s, &o);
return (r);
}
- bytes_skipped = (a->compression_skip)(a, tar->entry_bytes_remaining);
+
+ /*
+ * Compression layer skip functions are required to either skip the
+ * length requested or fail, so we can rely upon the entire entry
+ * plus padding being skipped.
+ */
+ bytes_skipped = (a->compression_skip)(a, tar->entry_bytes_remaining +
+ tar->entry_padding);
if (bytes_skipped < 0)
return (ARCHIVE_FATAL);
- /* same code as above in _tar_read_data() */
- tar->entry_bytes_remaining -= bytes_skipped;
- while (tar->sparse_list != NULL &&
- tar->sparse_list->remaining == 0) {
+
+ tar->entry_bytes_remaining = 0;
+ tar->entry_padding = 0;
+
+ /* Free the sparse list. */
+ while (tar->sparse_list != NULL) {
p = tar->sparse_list;
tar->sparse_list = p->next;
free(p);
- if (tar->sparse_list != NULL)
- tar->entry_offset = tar->sparse_list->offset;
}
- if (tar->sparse_list != NULL) {
- if (tar->sparse_list->remaining < bytes_skipped)
- bytes_skipped = tar->sparse_list->remaining;
- tar->sparse_list->remaining -= bytes_skipped;
- }
- tar->entry_offset += bytes_skipped;
- tar->entry_bytes_remaining -= bytes_skipped;
- /* Reuse padding code above. */
- while (r == ARCHIVE_OK)
- r = archive_read_format_tar_read_data(a, &b, &s, &o);
- return (r);
+
+ return (ARCHIVE_OK);
}
/*
OpenPOWER on IntegriCloud