You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
System.ArgumentNullException thrown from ZipOutputStream when writing AES encrypted/Stored entries #322
Try to use ZipOutputStream to create an AES encrypted entry whose compressionMethod is set to Stored.
e.g.
using (var memoryStream = new MemoryStream())
{
using (var zipStream = new ZipOutputStream(memoryStream))
{
zipStream.IsStreamOwner = false;
zipStream.Password = "password"; // optional. Null is the same as not setting. Required if using AES.
ZipEntry zipEntry = new ZipEntry("stored");
zipEntry.AESKeySize = 256;
zipEntry.DateTime = DateTime.Now;
zipEntry.CompressionMethod = CompressionMethod.Stored;
zipStream.PutNextEntry(zipEntry);
byte[] dummyData = Encoding.UTF8.GetBytes(DummyDataString);
using (var dummyStream = new MemoryStream(dummyData))
{
dummyStream.CopyTo(zipStream);
}
zipStream.CloseEntry();
}
}
Expected behavior
The entry should be added
Actual behavior
The call to CloseEntry() throws an ArgumentNullException.
Activity
Numpsy commentedon Feb 18, 2019
Problem seems to be that the AESAuthCode property of the output stream isn't set up in this case, so the attempt to use it @
SharpZipLib/src/ICSharpCode.SharpZipLib/Zip/ZipOutputStream.cs
Line 493 in 25ee644
See referenced PR for a possible fix.
Numpsy commentedon Mar 11, 2019
Should be fixed by #323, so i'll close this now.