Malformed zip file should throw ZipException or BadReadException, not IOException


From http://dotnetzip.codeplex.com/discussions/261961
I think that a malformed zip file should throw ZipException or BadReadException when calling ZipFile.Read(). The following code throws an IOException with the message "An attempt was made to move the file pointer before the beginning of the file."
Stack Trace:
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) at System.IO.FileStream.SeekCore(Int64 offset, SeekOrigin origin) at System.IO.FileStream.Seek(Int64 offset, SeekOrigin origin) at Ionic.Zip.ZipFile.ReadIntoInstance(ZipFile zf) at Ionic.Zip.ZipFile.Read(String fileName, TextWriter statusMessageWriter, Encoding encoding, EventHandler`1 readProgress)
string filePath = Path.GetTempFileName();
File.WriteAllText( filePath , "asdfasdf" );
string outputDirectory = Path.GetTempPath();
using ( ZipFile zipFile = ZipFile.Read( filePath ) )
 zipFile.ExtractAll( outputDirectory  ); }
Closed Jun 22, 2011 at 2:58 AM by Cheeso
fixed in changeset 79591. First binary to get this fix: v1.9.1.6


Cheeso wrote Jun 22, 2011 at 2:57 AM

I think you're right.