Skip to content

Commit af7187d

Browse files
authored
Fix wrong entry write handling
1 parent 2e4a62b commit af7187d

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

src/ICSharpCode.SharpZipLib/Zip/ZipOutputStream.cs

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -782,25 +782,26 @@ public override void Write(byte[] buffer, int offset, int count)
782782

783783
if (curEntry.AESKeySize == 0 && !entryIsPassthrough)
784784
{
785-
// Only update CRC if AES is not enabled
785+
// Only update CRC if AES is not enabled and entry is not a passthrough one
786786
crc.Update(new ArraySegment<byte>(buffer, offset, count));
787787
}
788788

789789
size += count;
790790

791-
if(curMethod == CompressionMethod.Deflated)
791+
if(curMethod == CompressionMethod.Stored || entryIsPassthrough)
792792
{
793-
base.Write(buffer, offset, count);
794-
return;
795-
}
796-
797-
if (Password != null)
798-
{
799-
CopyAndEncrypt(buffer, offset, count);
793+
if (Password != null)
794+
{
795+
CopyAndEncrypt(buffer, offset, count);
796+
}
797+
else
798+
{
799+
baseOutputStream_.Write(buffer, offset, count);
800+
}
800801
}
801802
else
802803
{
803-
baseOutputStream_.Write(buffer, offset, count);
804+
base.Write(buffer, offset, count);
804805
}
805806
}
806807

0 commit comments

Comments
 (0)