From 54f74a3b117542672cbacf51182bb1286441688b Mon Sep 17 00:00:00 2001 From: Tim Kientzle Date: Sat, 28 Dec 2013 15:30:04 -0800 Subject: Update some comments --- libarchive/archive_read_support_format_zip.c | 32 +++++++++++++++++++++------- 1 file changed, 24 insertions(+), 8 deletions(-) (limited to 'libarchive/archive_read_support_format_zip.c') 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; -- cgit v1.2.1