summaryrefslogtreecommitdiff
path: root/libarchive/archive_write_set_format_zip.c
diff options
context:
space:
mode:
authorTim Kientzle <kientzle@acm.org>2013-12-26 23:00:30 -0800
committerTim Kientzle <kientzle@acm.org>2013-12-26 23:00:30 -0800
commitba0a8af98db13a9223a62216cf2779df41bb03a9 (patch)
tree1efe96c412d8819892f7c8aad88d62f2116551bf /libarchive/archive_write_set_format_zip.c
parent0a6a1d9996d86d82928c323572058752c8d2226e (diff)
downloadlibarchive-ba0a8af98db13a9223a62216cf2779df41bb03a9.tar.gz
Finish the detailed verification of zip archive with single entry for both zip64 and non-zip64 cases.
Fix a few minor issues this uncovers.
Diffstat (limited to 'libarchive/archive_write_set_format_zip.c')
-rw-r--r--libarchive/archive_write_set_format_zip.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/libarchive/archive_write_set_format_zip.c b/libarchive/archive_write_set_format_zip.c
index a1dc33ac..ca351857 100644
--- a/libarchive/archive_write_set_format_zip.c
+++ b/libarchive/archive_write_set_format_zip.c
@@ -473,24 +473,31 @@ archive_write_zip_header(struct archive_write *a, struct archive_entry *entry)
if (zip->entry_compression == COMPRESSION_UNSPECIFIED) {
zip->entry_compression = COMPRESSION_DEFAULT;
}
- if (zip->force_zip64 /* User has forced it. */
- || zip->entry_uncompressed_size > 0xffffffffLL) /* Large entry. */
- zip->entry_uses_zip64 = 1;
if (zip->entry_compression == COMPRESSION_STORE) {
zip->entry_compressed_size = size;
zip->entry_uncompressed_size = size;
version_needed = 10;
} else {
+ zip->entry_uncompressed_size = size;
version_needed = 20;
}
+ if (zip->force_zip64 /* User has forced it. */
+ || zip->entry_uncompressed_size > 0xffffffffLL) { /* Large entry. */
+ zip->entry_uses_zip64 = 1;
+ version_needed = 45;
+ }
+
/* We may know the size, but never the CRC. */
zip->entry_flags |= ZIP_FLAGS_LENGTH_AT_END;
} else {
- /* Prefer deflate if it's available. */
+ /* Prefer deflate if it's available, because deflate
+ * has a clear end-of-data marker that makes
+ * length-at-end more reliable. */
zip->entry_compression = COMPRESSION_DEFAULT;
zip->entry_flags |= ZIP_FLAGS_LENGTH_AT_END;
if (!zip->avoid_zip64) {
zip->entry_uses_zip64 = 1;
+ version_needed = 45;
} else if (zip->entry_compression == COMPRESSION_STORE) {
version_needed = 10;
} else {
@@ -498,10 +505,6 @@ archive_write_zip_header(struct archive_write *a, struct archive_entry *entry)
}
}
- if (zip->entry_uses_zip64) {
- version_needed = 45;
- }
-
/* Format the local header. */
memset(local_header, 0, sizeof(local_header));
memcpy(local_header, "PK\003\004", 4);