2

Closed

ZipOutputStream corrupts data buffer when calling Write(byte[],int,int)

description

First off, thanks for the brilliant library and all the effort that has gone into it.
 
I've found that when I write data to a ZipOutputStream the data buffer is corrupted afterwords. I've looked through the documentation, but didn't find a warning indicating that such a side-effect is intended. Is this due to the encryption I'm enabling?
 
Here is a little example which reproduces the problem. If I use ZipFile instead of ZipOutputStream the buffer doesn't get corrupted.
 
 
 
 
var content = new byte[1789];
unchecked
{
byte b = 0;
for (var i = 0; i < content.Length; i&#43;&#43;, b&#43;&#43;)
{
    content[i] = b;
}
}
 
using (var fileStream = File.OpenWrite("temp.zip"))
{
using(var zipStream = new ZipOutputStream(fileStream, true))
{
    zipStream.CompressionLevel = CompressionLevel.None;
    zipStream.Password = "mydummypassword";
    zipStream.Encryption = EncryptionAlgorithm.WinZipAes256;
    zipStream.PutNextEntry("myentry.myext");
    zipStream.Write(content, 0, content.Length);
}
}
 
unchecked
{
byte b = 0;
for (var i = 0; i < content.Length; i&#43;&#43;, b&#43;&#43;)
{
    if (content[i] != b)
    {
        Console.WriteLine("Buffer was modified.");
    }
}
}
Closed Jun 16, 2011 at 6:32 PM by Cheeso
good bug, thanks for reporting it. This is fixed in changeset 79280, the first binary with this fix in it will be v1.9.1.6.

comments