Skip to content

Commit

Permalink
zip: fix zip64 headers (#313)
Browse files Browse the repository at this point in the history
See also golang/go#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.

Co-authored-by: Joshua Boelter <joshua.boelter@intel.com>
  • Loading branch information
jboelter and jboelterintc authored Jan 25, 2021
1 parent 1947972 commit b6bab90
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion zip/writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down

0 comments on commit b6bab90

Please sign in to comment.