Skip to content

System.ArgumentNullException thrown from ZipOutputStream when writing AES encrypted/Stored entries #322

@Numpsy

Description

@Numpsy

Steps to reproduce

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.

Version of SharpZipLib

Obtained from (only keep the relevant lines)

  • Compiled from source, commit: 25ee644

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions