Skip to content

Commit

Permalink
Merge pull request #792 from DannyBoyk/791_Correct_EOCD_ZipWriter
Browse files Browse the repository at this point in the history
ZipWriter: Write correct EOCD record when more than 65,535 files
  • Loading branch information
adamhathcock authored Dec 27, 2023
2 parents 372a2c8 + d4fb17c commit 2d4ce30
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 2d4ce30

Please sign in to comment.