Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

InflaterInputStream throws 'Invalid input data' when unpacking certain files using RC1 #253

Closed
1 of 8 tasks
DmitriyKirakosyan opened this issue Jul 16, 2018 · 7 comments
Closed
1 of 8 tasks
Assignees
Labels
bug zip Related to ZIP file format

Comments

@DmitriyKirakosyan
Copy link

DmitriyKirakosyan commented Jul 16, 2018

Steps to reproduce

  1. Get zip with .jar file inside
  2. Unpack it using FastZip or https://github.com/icsharpcode/SharpZipLib/wiki/Zip-Samples
  3. Observe the exception:
ICSharpCode.SharpZipLib.Zip.ZipException: Invalid input data
  at ICSharpCode.SharpZipLib.Zip.Compression.Streams.InflaterInputStream.Read (System.Byte[] buffer, System.Int32 offset, System.Int32 count) [0x00064] in <c593097fc4b94ac1b244b4fb8b18cca4>:0 
  at ICSharpCode.SharpZipLib.Core.StreamUtils.Copy (System.IO.Stream source, System.IO.Stream destination, System.Byte[] buffer) [0x00048] in <c593097fc4b94ac1b244b4fb8b18cca4>:0 

Expected behavior

Should successfully unzip an archive.

Actual behavior

Throws exception when unzipping .jar file

Version of SharpZipLib

1.0.0-rc1

Obtained from (place an x between the brackets for all that apply)

  • Compiled from source
  • branch: _______
  • commit: _______
  • Downloaded DLL from GitHub
  • Downloaded DLL from SourceForge
  • Downloaded DLL from _______
  • DLL included as part of
  • Package installed using:
  • NuGet
  • MyGet
  • Chocolatey
@piksel piksel self-assigned this Jul 16, 2018
@piksel piksel added bug zip Related to ZIP file format labels Jul 16, 2018
@piksel
Copy link
Member

piksel commented Jul 18, 2018

I am not able to reproduce the error, could you show your code and upload the problematic file?
You can upload it by dragging it to the textbox.

Test sample created using:

echo "content" > test.txt
jar cf test.jar test.txt
7z a test.zip test.jar

Running simple repro project:
https://gist.github.com/piksel/426a492933a2421bfd10d40f2b2f0335

D:\tmp> dotnet run -- test.zip
Extracting contents of test.zip to out...

D:\tmp> dir out
Directory: D:\tmp\out
Mode                LastWriteTime         Length Name
----                -------------         ------ ----
-a----       2018-07-18     20:26            459 test.jar

@johnfedak
Copy link

I had to back out the RC due what I think is the same issue.
The files that were failing were gziped text files.

@piksel
Copy link
Member

piksel commented Jul 18, 2018

@johnfedak
Copy link

Yes, that appears to have addressed the issue. Thanks.

@DmitriyKirakosyan
Copy link
Author

@piksel Just realised that not all jars cause the issue. To reproduce it you can simply take this google's zip file.
Sorry that I didn't test it on a simple jar file.

I've tested the package from #253 (comment), and indeed it seems working to me.

Would be nice to see it in master and the NuGet updated 🤩

@263613093
Copy link

SharpZipLib version 1.0.0-rc-1

unpacking zip file throw exception

StackTrace as:
at ICSharpCode.SharpZipLib.Zip.Compression.Streams.InflaterInputStream.Read(Byte[] buffer, Int32 offset, Int32 count)
at ICSharpCode.SharpZipLib.Zip.ZipInputStream.BodyRead(Byte[] buffer, Int32 offset, Int32 count)
at ICSharpCode.SharpZipLib.Zip.ZipInputStream.InitialRead(Byte[] destination, Int32 offset, Int32 count)
at ICSharpCode.SharpZipLib.Zip.ZipInputStream.Read(Byte[] buffer, Int32 offset, Int32 count)
at ConsoleAppTest.Utility.ZipHelper.ChangePackage(String zipSource, String sourcePassword, String destZip, String destPassword, IEnumerable1 newFiles, IEnumerable1 delFiles) in D:\Others\Demo\ConsoleAppTest\Utility\ZipHelper.cs:line 84
at.....

when i uninstall this version and then install v0.86.0
it can unpacking zip file success!

@piksel
Copy link
Member

piksel commented Jul 19, 2018

@263613093, yes this does indeed seem to be the same bug. I will be releasing RC2 shortly with the fix.

@piksel piksel changed the title Getting Exception 'Invalid input data' when unpacking archive with jar file inside InflaterInputStream throws 'Invalid input data' when unpacking certain files using RC1 Jul 19, 2018
@piksel piksel closed this as completed in 796b5be Jul 20, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug zip Related to ZIP file format
Projects
None yet
Development

No branches or pull requests

4 participants