adamhathcock / sharpcompress

SharpCompress is a fully managed C# library to deal with many compression types and formats.
MIT License
2.25k stars 479 forks source link

ZIP Header Version too high for Adnroid/Java zip extractor #102

Closed pappe82 closed 8 years ago

pappe82 commented 8 years ago

Creating a ZIP-file with sharpcompress creates Zip-Entries with the entry version set to 63 (constant), no matter which compression algorithm is chosen. The zip-Classes in java.util.zip check this Version and refuse to decompress, if this version is higher than 20, although there is no problem decompressing them, if manually set to 20.

This means, it is not possible to decompress the created archives using the java classes, especially on Android-devices.

Is there any reason to set the higher 63 as version for the entry? if not, could you please reconsider setting it down to 20? Almost every other zip-program I used for testing this issue uses smaller version numbers.

I changed the sources (all hail open source) and everything works now, but I would prefer to use the NuGet package for easier updating in my solution.

adamhathcock commented 8 years ago

Which headers?

I'm guessing you're referring to the version needed to extract flag in the directory header. Which could be set to lower if using deflate. Sounds like a good pull request.

pappe82 commented 8 years ago

In the ZipWriterClass, WriteHeader method, there is the line: OutputStream.Write(new byte[] { 63, 0 }, 0, 2); //version It does not distinguish different algorithms, it's always 63 here. I set it down to 20 as I am using deflate to create my archives and it works like a charm. Funny thing, the ZipCentralDirectoryEntry also uses the Version 63, I only changed it in the line shown above, but the java libs seem to ignore it there. Do you need any more Information on this issue?

adamhathcock commented 8 years ago

I think I understand. I would just rather have a pull request as my own time is limited these days.

pappe82 commented 8 years ago

Made my first GitHub pull request. I hope, I did everything right. Can you estimate, how long it may take you to include those changes?

adamhathcock commented 8 years ago

Thanks. I'll try to remember tonight if the baby will sleep.

pappe82 commented 8 years ago

Well, I know that feeling good luck!

pappe82 commented 8 years ago

Thank you for the fast response. I only have one more question - do you plan to release a new nuget package soon? I just noticed, the package under https://www.nuget.org/packages/sharpcompress/ seems to be outdated.

adamhathcock commented 8 years ago

https://www.nuget.org/packages/sharpcompress/0.11.2 Just did it. Didn't get the time to finish last night.

pappe82 commented 8 years ago

Thank you so much!