From 75de90ac7f48a73026924b81eeb579ab72dbf5e5 Mon Sep 17 00:00:00 2001 From: Tim Kientzle Date: Sat, 3 May 2014 22:59:31 -0700 Subject: [PATCH] Zip: Adjust streaming extension field to match the final spec worked out with Info-Zip folks --- libarchive/archive_read_support_format_zip.c | 4 ++-- libarchive/archive_write_set_format_zip.c | 16 ++++++---------- .../test_write_format_zip_compression_store.c | 4 ++-- libarchive/test/test_write_format_zip_file.c | 2 +- .../test/test_write_format_zip_file_zip64.c | 2 +- 5 files changed, 12 insertions(+), 16 deletions(-) diff --git a/libarchive/archive_read_support_format_zip.c b/libarchive/archive_read_support_format_zip.c index dbe245e15..cbafe2279 100644 --- a/libarchive/archive_read_support_format_zip.c +++ b/libarchive/archive_read_support_format_zip.c @@ -341,9 +341,9 @@ process_extra(const char *p, size_t extra_length, struct zip_entry* zip_entry) } break; } - case 0x6c65: + case 0x6c78: { - /* Experimental 'el' field */ + /* Experimental 'xl' field */ /* * Introduced Dec 2013 to provide a way to * include external file attributes in local file diff --git a/libarchive/archive_write_set_format_zip.c b/libarchive/archive_write_set_format_zip.c index 6ecf468c4..332611c86 100644 --- a/libarchive/archive_write_set_format_zip.c +++ b/libarchive/archive_write_set_format_zip.c @@ -82,10 +82,6 @@ struct cd_segment { unsigned char *p; }; -/* Bits used to enable/disable certain experimental features. */ -#define EXPERIMENT_LA 1 -#define EXPERIMENTS_ALL 0xffff - struct zip { int64_t entry_offset; @@ -119,7 +115,7 @@ struct zip { #define ZIP_FLAG_AVOID_ZIP64 1 #define ZIP_FLAG_FORCE_ZIP64 2 -#define ZIP_FLAG_EXPERIMENT_EL 4 +#define ZIP_FLAG_EXPERIMENT_xl 4 int flags; #ifdef HAVE_ZLIB_H @@ -229,9 +225,9 @@ archive_write_zip_options(struct archive_write *a, const char *key, return (ret); } else if (strcmp(key, "experimental") == 0) { if (val == NULL || val[0] == 0) { - zip->flags &= ~ ZIP_FLAG_EXPERIMENT_EL; + zip->flags &= ~ ZIP_FLAG_EXPERIMENT_xl; } else { - zip->flags |= ZIP_FLAG_EXPERIMENT_EL; + zip->flags |= ZIP_FLAG_EXPERIMENT_xl; } return (ARCHIVE_OK); } else if (strcmp(key, "fakecrc32") == 0) { @@ -695,11 +691,11 @@ archive_write_zip_header(struct archive_write *a, struct archive_entry *entry) archive_le16enc(zip64_start + 2, e - (zip64_start + 4)); } - if (zip->flags & ZIP_FLAG_EXPERIMENT_EL) { - /* Experimental 'el' extension to improve streaming. */ + if (zip->flags & ZIP_FLAG_EXPERIMENT_xl) { + /* Experimental 'xl' extension to improve streaming. */ unsigned char *external_info = e; int included = 7; - memcpy(e, "el\000\000", 4); // 0x6c65 + 2-byte length + memcpy(e, "xl\000\000", 4); // 0x6c65 + 2-byte length e += 4; e[0] = included; /* bitmap of included fields */ e += 1; diff --git a/libarchive/test/test_write_format_zip_compression_store.c b/libarchive/test/test_write_format_zip_compression_store.c index 063c1b04e..c6761f9df 100644 --- a/libarchive/test/test_write_format_zip_compression_store.c +++ b/libarchive/test/test_write_format_zip_compression_store.c @@ -231,7 +231,7 @@ DEFINE_TEST(test_write_format_zip_compression_store) assertEqualInt(i4(q + 11), file_gid); /* 'Ux' GID */ q = q + 4 + i2(q + 2); - assertEqualInt(i2(q), 0x6c65); /* 'el' experimental extension header */ + assertEqualInt(i2(q), 0x6c78); /* 'xl' experimental extension header */ assertEqualInt(i2(q + 2), 9); /* size */ assertEqualInt(q[4], 7); /* Bitmap of fields included. */ assertEqualInt(i2(q + 5) >> 8, 3); /* system & version made by */ @@ -320,7 +320,7 @@ DEFINE_TEST(test_write_format_zip_compression_store) assertEqualInt(i4(q + 11), folder_gid); /* 'ux' GID */ q = q + 4 + i2(q + 2); - assertEqualInt(i2(q), 0x6c65); /* 'el' experimental extension header */ + assertEqualInt(i2(q), 0x6c78); /* 'xl' experimental extension header */ assertEqualInt(i2(q + 2), 9); /* size */ assertEqualInt(q[4], 7); /* bitmap of fields */ assertEqualInt(i2(q + 5) >> 8, 3); /* system & version made by */ diff --git a/libarchive/test/test_write_format_zip_file.c b/libarchive/test/test_write_format_zip_file.c index b58c1abbf..efac7d883 100644 --- a/libarchive/test/test_write_format_zip_file.c +++ b/libarchive/test/test_write_format_zip_file.c @@ -218,7 +218,7 @@ DEFINE_TEST(test_write_format_zip_file) assertEqualInt(i4(p + 11), file_gid); /* 'Ux' GID */ p += 4 + i2(p + 2); - assertEqualInt(i2(p), 0x6c65); /* 'el' experimental extension block */ + assertEqualInt(i2(p), 0x6c78); /* 'xl' experimental extension block */ assertEqualInt(i2(p + 2), 9); /* size */ assertEqualInt(p[4], 7); /* bitmap of fields in this block */ assertEqualInt(i2(p + 5) >> 8, 3); /* System & version made by */ diff --git a/libarchive/test/test_write_format_zip_file_zip64.c b/libarchive/test/test_write_format_zip_file_zip64.c index 9cd04ab1d..def6809a4 100644 --- a/libarchive/test/test_write_format_zip_file_zip64.c +++ b/libarchive/test/test_write_format_zip_file_zip64.c @@ -252,7 +252,7 @@ DEFINE_TEST(test_write_format_zip_file_zip64) /* compressed file size we can't verify here */ p += 4 + i2(p + 2); - assertEqualInt(i2(p), 0x6c65); /* 'el' experimental extension header */ + assertEqualInt(i2(p), 0x6c78); /* 'xl' experimental extension header */ assertEqualInt(i2(p + 2), 9); /* size */ assertEqualInt(p[4], 7); /* bitmap of included fields */ assertEqualInt(i2(p + 5) >> 8, 3); /* system & version made by */ -- 2.47.2