This is a migrated thread and some comments may be shown as answers.

ZipArchive Exception type with bad password

1 Answer 152 Views
ZipLibrary
This is a migrated thread and some comments may be shown as answers.
Josh
Top achievements
Rank 1
Josh asked on 19 Aug 2015, 03:15 PM

Is there a reliable way to detect a bad password when opening a ZipArchive?  I'm currently getting an InvalidOperationException when reading the first entry, and the message is a generic "Invalid data".  Exception shared below.

 

Telerik.Windows.Zip.InvalidDataException occurred
  HResult=-2146233088
  Message=Invalid data
  Source=Telerik.Windows.Zip
  StackTrace:
       at Telerik.Windows.Zip.DeflateDecompressor.SetPreviousCode() in c:\TB\221\WPF_Scrum\Release_WPF\Sources\Development\Frameworks\Zip\Compression\Deflate\DeflateDecompressor.cs:line 630
       at Telerik.Windows.Zip.DeflateDecompressor.ReadTreeCodes() in c:\TB\221\WPF_Scrum\Release_WPF\Sources\Development\Frameworks\Zip\Compression\Deflate\DeflateDecompressor.cs:line 589
       at Telerik.Windows.Zip.DeflateDecompressor.DecodeDynamicBlockHeader() in c:\TB\221\WPF_Scrum\Release_WPF\Sources\Development\Frameworks\Zip\Compression\Deflate\DeflateDecompressor.cs:line 534
       at Telerik.Windows.Zip.DeflateDecompressor.CheckDecodeState() in c:\TB\221\WPF_Scrum\Release_WPF\Sources\Development\Frameworks\Zip\Compression\Deflate\DeflateDecompressor.cs:line 274
       at Telerik.Windows.Zip.DeflateDecompressor.Decode() in c:\TB\221\WPF_Scrum\Release_WPF\Sources\Development\Frameworks\Zip\Compression\Deflate\DeflateDecompressor.cs:line 233
       at Telerik.Windows.Zip.DeflateDecompressor.Inflate(Byte[] bytes, Int32 offset, Int32 length) in c:\TB\221\WPF_Scrum\Release_WPF\Sources\Development\Frameworks\Zip\Compression\Deflate\DeflateDecompressor.cs:line 736
       at Telerik.Windows.Zip.DeflateDecompressor.ProcessTransform(Boolean finalBlock) in c:\TB\221\WPF_Scrum\Release_WPF\Sources\Development\Frameworks\Zip\Compression\Deflate\DeflateDecompressor.cs:line 181
       at Telerik.Windows.Zip.CompressionTransformBase.TransformFinalBlock(Byte[] inputBuffer, Int32 inputOffset, Int32 inputCount) in c:\TB\221\WPF_Scrum\Release_WPF\Sources\Development\Frameworks\Zip\Compression\CompressionTransformBase.cs:line 162
       at Telerik.Windows.Zip.OperationStream.Read(Byte[] buffer, Int32 offset, Int32 count) in c:\TB\221\WPF_Scrum\Release_WPF\Sources\Development\Frameworks\Zip\OperationStream.cs:line 395
       at Telerik.Windows.Zip.CompressedStream.Read(Byte[] buffer, Int32 offset, Int32 count) in c:\TB\221\WPF_Scrum\Release_WPF\Sources\Development\Frameworks\Zip\Compression\CompressedStream.cs:line 155
       at System.IO.Stream.InternalCopyTo(Stream destination, Int32 bufferSize)
       at System.IO.Stream.CopyTo(Stream destination)
       at PacketMonitor.BinaryLog.LogReader.Open(String fileName, String password)
  InnerException: 

1 Answer, 1 is accepted

Sort by
0
Petya
Telerik team
answered on 24 Aug 2015, 12:24 PM
Hi Josh,

I confirmed the behavior and logged it in our backlog for further investigation and fix. I also updated your Telerik points in appreciation of the report and you can track the team's progress on this using this item in the public portal: Reading password-protected archive with password throws exception.

I'm afraid I'm unable to provide another workaround but to surround the accessing of the archive entries in a try-catch block.

Regards,
Petya
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
ZipLibrary
Asked by
Josh
Top achievements
Rank 1
Answers by
Petya
Telerik team
Share this question
or