Skip to content

Commit 500dbba

Browse files
committed
Z-1724 ZipOutputStream set Compressed Size incorrectly in local header when CRC and Size are known.
1 parent af0ee8d commit 500dbba

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

src/Zip/ZipOutputStream.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
// HISTORY
4141
// 22-12-2009 Z-1649 Added AES support
4242
// 22-02-2010 Z-1648 Zero byte entries would create invalid zip files
43+
// 27-07-2012 Z-1724 Compressed size was incorrect in local header when CRC and Size are known
4344

4445
using System;
4546
using System.IO;
@@ -280,7 +281,7 @@ public void PutNextEntry(ZipEntry entry)
280281
}
281282
else
282283
{
283-
headerInfoAvailable = (entry.Size >= 0) && entry.HasCrc;
284+
headerInfoAvailable = (entry.Size >= 0) && entry.HasCrc && entry.CompressedSize >= 0;
284285

285286
// Switch to deflation if storing isnt possible.
286287
if (method == CompressionMethod.Stored)
@@ -343,7 +344,7 @@ public void PutNextEntry(ZipEntry entry)
343344
WriteLeInt((int)entry.DosTime);
344345

345346
// TODO: Refactor header writing. Its done in several places.
346-
if (headerInfoAvailable == true) {
347+
if (headerInfoAvailable) {
347348
WriteLeInt((int)entry.Crc);
348349
if ( entry.LocalHeaderRequiresZip64 ) {
349350
WriteLeInt(-1);

0 commit comments

Comments
 (0)