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
Streaming to unseekable stream produces invalid archive #545
Comments
Looks to me like the .NET Core 2.0 version of ZipArchive actually creates the entry with Deflate compression rather than storing it, whereas the Core 3.1 and .NET 5 versions do store it. With .NET Core 2: With .NET 5: ZipInputStream can't extract stored entries that have a descriptor (#517), so an error would be expected in this case. As to why the .NET versions might behave differently - dotnet/corefx#33345 perhaps? |
Yeah, as @Numpsy pointed out, that is probably the reason for why they are different.
...unless you're reading the archive as a stream :/ I am a bit confused though, you create the zip file with |
fwiw, I tried building the SharpZipLib unit tests as .NET 5, and they all passed. |
Yeah, I have been running almost exclusively .NET 5 since first RC. There is a fix for this, but it needs to be done in This is what they output now: .NET 5 unseekable.zip |
Aaahh, yes, I didn't notice this. Does this mean I could do the same using SharpZipLib and it'd work? But yeah, seems to be a bug of |
If I recall correctly, yes, but I'd have to check the source since I am not sure what has been merged and not. I believe we still do the deflate "trick" for non-compressed data. |
Think that's the bit that #407 would have changed, before it was dropped for this sort of reason? |
Yeah, I mean, #407 would've done the same as the change in |
You could maybe have a variant of PutNextEntry that took the details of an entry and the data, then compressed the data in memory, did the CRC and such, and wrote the data to the output stream in a one-shot operation? (not sure if that quite fits with the architecture though, and could need an arbitrarty amount of memory to just compress in memory) |
@Numpsy, sure, but you could also do that today by just writing to a |
Closing this as it is due to changes in |
There seems to be a Regression in SharpZipLib when upgrading from netcoreapp2 to net5.
In net5, creating a ziparchive on the fly, targeting an unseekable stream, produces an invalid archive.
In netcoreapp2, this is not the case.
I've documented this in the following repo:
https://github.com/VanCoding/SharpZipLib-unseekable-bug
This should make it as convenient as possible to reproduce it.
The text was updated successfully, but these errors were encountered: