summaryrefslogtreecommitdiff
path: root/libarchive/archive_read_support_format_zip.c
diff options
context:
space:
mode:
authorTim Kientzle <kientzle@acm.org>2013-12-28 15:30:04 -0800
committerTim Kientzle <kientzle@acm.org>2013-12-28 15:30:04 -0800
commit54f74a3b117542672cbacf51182bb1286441688b (patch)
tree2b23016243c7e941a88a89939f9d53573e603acc /libarchive/archive_read_support_format_zip.c
parent4e6e749cf628c27f26d2183bb04de12890595c32 (diff)
downloadlibarchive-54f74a3b117542672cbacf51182bb1286441688b.tar.gz
Update some comments
Diffstat (limited to 'libarchive/archive_read_support_format_zip.c')
-rw-r--r--libarchive/archive_read_support_format_zip.c32
1 files changed, 24 insertions, 8 deletions
diff --git a/libarchive/archive_read_support_format_zip.c b/libarchive/archive_read_support_format_zip.c
index 3e7bb185..3f102126 100644
--- a/libarchive/archive_read_support_format_zip.c
+++ b/libarchive/archive_read_support_format_zip.c
@@ -1102,10 +1102,6 @@ archive_read_format_zip_streamable_read_header(struct archive_read *a,
while (p + 4 <= end) {
if (p[0] == 'P' && p[1] == 'K') {
- if (p[2] == '\001' && p[3] == '\002')
- /* Beginning of central directory. */
- return (ARCHIVE_EOF);
-
if (p[2] == '\003' && p[3] == '\004') {
/* Regular file entry. */
zip_read_consume(a, skipped);
@@ -1113,9 +1109,26 @@ archive_read_format_zip_streamable_read_header(struct archive_read *a,
entry, zip);
}
- if (p[2] == '\005' && p[3] == '\006')
- /* End of central directory. */
- return (ARCHIVE_EOF);
+ /*
+ * TODO: We cannot restore symlinks or
+ * permissions based only on the local
+ * file headers. Consider scanning
+ * the central directory and returning
+ * additional entries for at least
+ * symlinks and directories. This
+ * would allow us to correctly restore
+ * symlinks and directory permissions
+ * even when streaming.
+ */
+ if (p[2] == '\001' && p[3] == '\002') {
+ return (ARCHIVE_EOF);
+ }
+
+ /* End of central directory? Must be an
+ * empty archive. */
+ if ((p[2] == '\005' && p[3] == '\006')
+ || (p[2] == '\006' && p[3] == '\006'))
+ return (ARCHIVE_EOF);
}
++p;
++skipped;
@@ -1161,12 +1174,15 @@ zip_read_local_file_header(struct archive_read *a, struct archive_entry *entry,
size_t len, filename_length, extra_length;
struct archive_string_conv *sconv;
struct zip_entry *zip_entry = zip->entry;
- struct zip_entry zip_entry_original = *zip_entry;
+ struct zip_entry zip_entry_original;
uint32_t local_crc32;
int64_t compressed_size, uncompressed_size;
int ret = ARCHIVE_OK;
char version;
+ /* Save a copy of the original for consistency checks. */
+ zip_entry_original = *zip_entry;
+
zip->decompress_init = 0;
zip->end_of_entry = 0;
zip->entry_uncompressed_bytes_read = 0;