Skip to content

Commit b6bab90

Browse files
zip: fix zip64 headers (#313)
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 <[email protected]>
1 parent 1947972 commit b6bab90

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

zip/writer.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ func (w *Writer) Close() error {
129129
b.uint16(uint16(len(h.Comment)))
130130
b = b[4:] // skip disk number start and internal file attr (2x uint16)
131131
b.uint32(h.ExternalAttrs)
132-
if h.offset > uint32max {
132+
if h.isZip64() || h.offset > uint32max {
133133
b.uint32(uint32max)
134134
} else {
135135
b.uint32(uint32(h.offset))

0 commit comments

Comments
 (0)