From 5ad44b42a877528448fd107a595ca9bf9f7c9b27 Mon Sep 17 00:00:00 2001 From: Joshua Boelter Date: Sun, 24 Jan 2021 21:16:15 -0800 Subject: [PATCH] fixes zip64 headers See also https://github.com/golang/go/issues/33116 The offset must be written into the central directory as 0xFFFFFFFF if it's going to be written in the zip64 extended information field. https://pkware.cachefly.net/webdocs/casestudies/APPNOTE.TXT The following is the layout of the zip64 extended information "extra" block. If one of the size or offset fields in the Local or Central directory record is too small to hold the required data, a Zip64 extended information record is created. The order of the fields in the zip64 extended information record is fixed, but the fields MUST only appear if the corresponding Local or Central directory record field is set to 0xFFFF or 0xFFFFFFFF. --- zip/writer.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zip/writer.go b/zip/writer.go index 335b637c8f..f7eb90da45 100644 --- a/zip/writer.go +++ b/zip/writer.go @@ -129,7 +129,7 @@ func (w *Writer) Close() error { b.uint16(uint16(len(h.Comment))) b = b[4:] // skip disk number start and internal file attr (2x uint16) b.uint32(h.ExternalAttrs) - if h.offset > uint32max { + if h.isZip64() || h.offset > uint32max { b.uint32(uint32max) } else { b.uint32(uint32(h.offset))