ZipArchive Exception type with bad password

2 posts, 0 answers
  1. Josh
    Josh avatar
    1 posts
    Member since:
    May 2013

    Posted 19 Aug 2015 Link to this post

    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: 

  2. Petya
    Admin
    Petya avatar
    975 posts

    Posted 24 Aug 2015 Link to this post

    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 wrong password throws generic 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
Back to Top