summaryrefslogtreecommitdiff
path: root/archive-zip.c
diff options
context:
space:
mode:
authorRené Scharfe <l.s.r@web.de>2017-04-27 22:25:45 +0200
committerJunio C Hamano <gitster@pobox.com>2017-04-28 10:07:59 +0900
commitebdfa294c9e280ee14de27cf9d4ffb2cf82d2f36 (patch)
treee98e94b704af5c29f2f39933988e51a87baa8519 /archive-zip.c
parent4cdf3f9d84568da72f1dcade812de7a42ecb6d15 (diff)
downloadgit-ebdfa294c9e280ee14de27cf9d4ffb2cf82d2f36.tar.gz
archive-zip: set version field for big files correctly
Signal that extractors need to implement spec version 4.5 (or higher) for files with sizes of 4GB and more. Older unzippers might produce truncated results otherwise; they should rather refuse to extract. Signed-off-by: Rene Scharfe <l.s.r@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'archive-zip.c')
-rw-r--r--archive-zip.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/archive-zip.c b/archive-zip.c
index 44ed78f163..e81c5ac15a 100644
--- a/archive-zip.c
+++ b/archive-zip.c
@@ -298,6 +298,7 @@ static int write_zip_entry(struct archiver_args *args,
int is_binary = -1;
const char *path_without_prefix = path + args->baselen;
unsigned int creator_version = 0;
+ unsigned int version_needed = 10;
size_t zip_dir_extra_size = ZIP_EXTRA_MTIME_SIZE;
size_t zip64_dir_extra_payload_size = 0;
@@ -382,8 +383,11 @@ static int write_zip_entry(struct archiver_args *args,
if (stream && size > 0x7fffffff)
need_zip64_extra = 1;
+ if (need_zip64_extra)
+ version_needed = 45;
+
copy_le32(header.magic, 0x04034b50);
- copy_le16(header.version, 10);
+ copy_le16(header.version, version_needed);
copy_le16(header.flags, flags);
copy_le16(header.compression_method, method);
copy_le16(header.mtime, zip_time);
@@ -509,7 +513,7 @@ static int write_zip_entry(struct archiver_args *args,
strbuf_add_le(&zip_dir, 4, 0x02014b50); /* magic */
strbuf_add_le(&zip_dir, 2, creator_version);
- strbuf_add_le(&zip_dir, 2, 10); /* version */
+ strbuf_add_le(&zip_dir, 2, version_needed);
strbuf_add_le(&zip_dir, 2, flags);
strbuf_add_le(&zip_dir, 2, method);
strbuf_add_le(&zip_dir, 2, zip_time);