GZipStream : Enforcing strict validation to detect truncated gzip files [.NET 9] #122572
Unanswered
ali-mazloum
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
.NET Version : 9.0
I'm working on a way to detect and process gzip files that may get corrupted somewhere in the environment, and was looking at using the .NET library GZipStream as such :
This works fine in most cases, but it doesn't seem as strict as other libraries when it comes to validating truncated files. For example, if I have a gzip file truncated halfway that is generated as such:
then the GZipStream library does not throw any exception, but a command such as
gunzip -tfails due to truncated data. The same can be observed if we generate a GZ file with the last 8 bytes removed (CRC + ISize)Is there a way to enforce strict validation using GZipStream that would be the equivalent of say the command
gunzip -ton unix systems?I saw other discussions around changing the GZipStream API to add strict validation, but it looks like it was later reversed, then put back in .NET8 , but I'm not sure if this covers the same case : #75671
Beta Was this translation helpful? Give feedback.
All reactions