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

Use streaming decompress to identify extent of compressed data. #66

Merged
merged 2 commits into from
Mar 7, 2024

Conversation

jgm
Copy link
Owner

@jgm jgm commented Mar 7, 2024

This fixes a problem that arises for local files with bit 3 of the general purpose bit flag set. In this case, we don't get information up front about the size of the compressed data. So how do we know where the compressed data ends? Previously, we tried to determine this by looking for the signature of the data descriptor. But this doesn't always HAVE a signature, and it is also possible for signatures to occur accidentally in the compressed data itself.

Here we follow a clue from an Info-ZIP note:
"In general, this feature can only be reliably used together with compression methods that allow intrinsic detection of the 'end-of-compressed-data' condition."

We use the streaming decompression interface from
zlib's Internal module. This tells us, in effect, where the compressed data ends.

Closes #65.

This fixes a problem that arises for local files with bit 3
of the general purpose bit flag set. In this case, we don't
get information up front about the size of the compressed
data.  So how do we know where the compressed data ends?
Previously, we tried to determine this by looking for the
signature of the data descriptor. But this doesn't always
HAVE a signature, and it is also possible for signatures to
occur accidentally in the compressed data itself.

Here we follow a clue from an Info-ZIP note:
"In general, this feature can only be reliably used
together with compression methods that allow intrinsic
detection of the 'end-of-compressed-data' condition."

We use the streaming decompression interface from
zlib's Internal module.  This tells us, in effect, where
the compressed data ends.

Closes #65.
We need to handle cases where there is no compression.
@jgm jgm marked this pull request as ready for review March 7, 2024 17:17
@jgm jgm merged commit 2abee35 into master Mar 7, 2024
14 checks passed
@jgm jgm deleted the issue65 branch March 7, 2024 17:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Error decoding archives since 4.3
1 participant