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

Zip: omit Disk Start Number from the Zip64 Central Directory Entry #6

Merged
merged 1 commit into from
Mar 13, 2024

Conversation

mihula
Copy link
Owner

@mihula mihula commented Mar 13, 2024

Clause 4.5.3 of the PKWare spec clearly states that it MUST only appear in the Extra block when the corresponding field in the CDE (or LDE) was set to -1 (0xFFFF in the case of the Disk Start Number.)

Previously, this would only be the case when Zip64 was presumed or the disk number was actually outside the range for the CDE. In every other case, the Disk Start Number would go into both locations, violating the spec.

Some tools (such as 7-Zip) show warnings in this case, but often work as expected. Others (such as older versions of System.IO.Compression) follow the spec more stringently and will refuse to use the values from the Zip64 Extra block when the related values do not match their expectation.

However, fixing this to always write a conformant CDE that has its Disk Start Number as 0xFFFF with the actual value in the Extra block breaks other tools (such as marmelroy/Zip on iOS) that do not fully support Zip64.

The spec does allow the Extra block to omit the Disk Start Number (and the Relativ Header Offset) when they fit in the CDE, so we do just that for general compatibility.

Fixes haf#260

Clause 4.5.3 of the PKWare spec clearly states that it MUST only appear in
the Extra block when the corresponding field in the CDE (or LDE) was set to
-1 (0xFFFF in the case of the Disk Start Number.)

Previously, this would only be the case when Zip64 was presumed or the disk
number was actually outside the range for the CDE. In every other case, the
Disk Start Number would go into both locations, violating the spec.

Some tools (such as 7-Zip) show warnings in this case, but often work as
expected. Others (such as older versions of System.IO.Compression) follow
the spec more stringently and will refuse to use the values from the Zip64
Extra block when the related values do not match their expectation.

However, fixing this to always write a conformant CDE that has its Disk
Start Number as 0xFFFF with the actual value in the Extra block breaks other
tools (such as marmelroy/Zip on iOS) that do not fully support Zip64.

The spec does allow the Extra block to omit the Disk Start Number (and the
Relativ Header Offset) when they fit in the CDE, so we do just that for
general compatibility.

Fixes haf#260
@mihula mihula marked this pull request as ready for review March 13, 2024 17:19
@mihula mihula merged commit b9e060e into main Mar 13, 2024
4 checks passed
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.

Zip64 writes incorrect central directory file header/extended information extra field
2 participants