1

Closed

Ensure consistency on exceptions on ZipFile.Read() failure.

description

ZipFile.Read(byte[] buffer) and ZipFile.Read(Stream zipStream) (if zipStream supports seeking) throw System.IO.IOException when zip file content has small amount of data but not empty. In large amount of data and empty data cases they throw Ionic.Zip.BadReadException.
 
There are some unit tests.
 
 
 
// this test fails
[TestMethod]
[ExpectedException(typeof(BadReadException))]
public void IncorrectZipContentTest1()
{
byte[] incorrectZipContent = Encoding.UTF8.GetBytes("wrong zipfile content");
ZipFile zipFile = ZipFile.Read(incorrectZipContent);
}
 
// this test succeeds
[TestMethod]
[ExpectedException(typeof(BadReadException))]
public void IncorrectZipContentTest2()
{
ZipFile zipFile = ZipFile.Read(new byte[0]);
}
 
// this test succeeds too
[TestMethod]
[ExpectedException(typeof(BadReadException))]
public void IncorrectZipContentTest3()
{
byte[] incorrectZipContent = new byte[8192];
ZipFile zipFile = ZipFile.Read(incorrectZipContent);
}
 
 
 
 
I think, first code snippet should throw Ionic.Zip.BadReadException too.
Closed Jun 18, 2011 at 11:50 PM by Cheeso
fixed in changeset 79403. First binary with this change: v1.9.1.6

comments