Skip to content

Commit

Permalink
ZipWriter: Write correct EOCD record when more than 65,535 files
Browse files Browse the repository at this point in the history
0xFFFF will be written to the EOCD to signal to use the ZIP64
CentralDirectory record when the number of files is 65,535 or more.
Fixes #791
  • Loading branch information
DannyBoyk committed Dec 22, 2023
1 parent 372a2c8 commit d4fb17c
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/SharpCompress/Writers/Zip/ZipWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,10 @@ private void WriteEndRecord(ulong size)

// Write normal end of central directory record
OutputStream.Write(stackalloc byte[] { 80, 75, 5, 6, 0, 0, 0, 0 });
BinaryPrimitives.WriteUInt16LittleEndian(intBuf, (ushort)entries.Count);
BinaryPrimitives.WriteUInt16LittleEndian(
intBuf,
(ushort)(entries.Count < 0xFFFF ? entries.Count : 0xFFFF)
);
OutputStream.Write(intBuf.Slice(0, 2));
OutputStream.Write(intBuf.Slice(0, 2));
BinaryPrimitives.WriteUInt32LittleEndian(intBuf, sizevalue);
Expand Down

0 comments on commit d4fb17c

Please sign in to comment.