Skip to content

unzip: Add support for Enhanced Deflated compression method#1236

Open
CrossVR wants to merge 6 commits into
madler:developfrom
CrossVR:enhanced-deflate
Open

unzip: Add support for Enhanced Deflated compression method#1236
CrossVR wants to merge 6 commits into
madler:developfrom
CrossVR:enhanced-deflate

Conversation

@CrossVR
Copy link
Copy Markdown

@CrossVR CrossVR commented May 9, 2026

This PR adds decompression support for the Enhanced Deflated compression method, also known under the PKZip trademark "Deflate64". This is most often encountered when dealing with zip files that were compressed using Windows Explorer or WinZip.

My main motivation for this PR is to make it less painful to implement support for this compression method by supporting it through the standard zlib API and to lower the maintenance burden of having to maintain a separate infback9 implementation.

This PR does not add support for this compression method for any other formats than zip files and is only supported in zlib through raw inflate API calls by passing in -16 as the window size or by passing a window size of 16 to the infback API.

I know that historically support for this format has been rejected, but I think it's worth revisiting some of the arguments mentioned in zlib's FAQ:

The compression method is proprietary

PKZip has their own implementation under an unregistered trademark, I could not find any patent on this variation of deflate. I don't think there's any issue as long as we don't use any trademarks.

The compression improvements are too small

It is indeed not worth implementing compression support, but I believe the compatibility improvements are substantial enough to warrant the changes to the inflate code.

Comment thread inftrees.c
const unsigned short dext[32] = { /* Distance codes 0..31 extra */
128, 128, 128, 128, 129, 129, 130, 130, 131, 131, 132, 132,
133, 133, 134, 134, 135, 135, 136, 136, 137, 137, 138, 138,
139, 139, 140, 140, 141, 141, wbits > 15 ? 142 : 64, wbits > 15 ? 142 : 64};
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I could make these static again so they don't get copied onto the stack, but I'll have to either duplicate the tables or add some extra logic below to override these table entries at runtime.

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.

1 participant