Skip to content

Reject 24 byte Zip64 extra field if disk number start is 0xFFFF. - #598

Open
DeNdlerX wants to merge 1 commit into
nih-at:mainfrom
DeNdlerX:fix/zip64-ef-disk
Open

DeNdlerX wants to merge 1 commit into
nih-at:mainfrom
DeNdlerX:fix/zip64-ef-disk

Conversation

@DeNdlerX

Copy link
Copy Markdown

Fixes #594.
The fallback for 24-byte Zip64 extra fields from 913b137 (#171) also accepted entries whose disk number start is 0xFFFF, although that layout has no room for a disk number. The disk number start then became 0 (the failed read was hidden by _zip_buffer_set_offset()) or a copy of one of the other values.
The fix remembers whether the disk number was read from the field and rejects that case with ZIP_ER_DETAIL_INVALID_ZIP64_EF, as for 16- and 20-byte fields. 28-byte fields and the #171 case (disk number start 0) are unchanged.

Such archives now fail to open with "invalid Zip64 extra field", with or without ZIP_CHECKCONS, instead of opening with a made-up disk number start.

New test open_incons_zip64_ef_disk opens four archives with a 24-byte field and disk number start 0xFFFF (the two from the issue and two other layouts); all are rejected. open_zip64_ef_unneeded_offset checks that the #171 layout (both sizes 0xFFFFFFFF, offset not, disk number start 0) still opens with ZIP_CHECKCONS.
Under LeakSanitizer open_incons_zip64_ef_disk only passes with #592 applied, because of the leak in tryopen fixed there.

Assisted-by: Claude Code (Opus 5.5)

A 24 byte Zip64 extra field is accepted if it contains uncompressed
size, compressed size and offset and they match the directory entry,
even if not all of them are 0xFFFFFFFF there (nih-at#171). That layout has
no room for the disk number. If disk number start was 0xFFFF, the disk
number was taken either from past the end of the field (0, because
_zip_buffer_set_offset() cleared the error of the failed read) or from
the bytes of one of the other values.

Assisted-by: Claude Code (Opus 5.5)
@dillof dillof added this to the later milestone Sep 30, 2026
@dillof dillof added the bug For issues, use type instead. label Sep 30, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug For issues, use type instead.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Zip64 extra field: 24-byte field with disk number 0xFFFF is accepted, disk number start taken from other fields

2 participants