Skip to content

fix: accept EOCD central-directory offsets above 16MB in zip - #180

Merged
kryptobi merged 1 commit into
mainfrom
fix/long-zip-files
Aug 4, 2026
Merged

fix: accept EOCD central-directory offsets above 16MB in zip#180
kryptobi merged 1 commit into
mainfrom
fix/long-zip-files

Conversation

@kryptobi

Copy link
Copy Markdown
Collaborator

ZIP based formats could fail validation for otherwise valid files when the EOCD "start of central directory offset" exceeded 0x00FFFFFF (~16MB). The previous EOCD tail check in Zip.EndsWith hardcoded 0x00 at byte 19 (MSB of the 4byte offset field), causing false negatives for large files.

Update the EOCD end pattern to treat the full offset bytes as variable (wildcards) instead of forcing a fixed MSB.

Impact:

  • Fixes false negatives for large ZIP containers and ZIP-based formats such as XLSX, DOCX, PPTX, ODS, ODT, and ODP.

Tests:

  • Add regression test for ZIP with EOCD central directory offset > 16MB.
  • Add regression test for XLSX with EOCD central directory offset > 16MB.

issues #178

@kryptobi

Copy link
Copy Markdown
Collaborator Author

@ james-francis-advanced fyi

ZIP based formats could fail validation for otherwise valid files when the
EOCD "start of central directory offset" exceeded 0x00FFFFFF (~16MB).
The previous EOCD tail check in Zip.EndsWith hardcoded 0x00 at byte 19
(MSB of the 4byte offset field), causing false negatives for large files.

Update the EOCD end pattern to treat the full offset bytes as variable
(wildcards) instead of forcing a fixed MSB.

Impact:
- Fixes false negatives for large ZIP containers and ZIP-based formats
  such as XLSX, DOCX, PPTX, ODS, ODT, and ODP.

Tests:
- Add regression test for ZIP with EOCD central directory offset > 16MB.
- Add regression test for XLSX with EOCD central directory offset > 16MB.

issues #178
@kryptobi
kryptobi force-pushed the fix/long-zip-files branch from 75a0dca to 866c39c Compare July 30, 2026 14:07
@kryptobi kryptobi self-assigned this Jul 31, 2026
@maxbreuker

Copy link
Copy Markdown
Contributor

@kryptobi Verified manually against this branch with two real files whose EOCD central-directory offset is above 16 MiB:

  • plain zip → matches Zip, unambiguous
  • xlsx → matches Xlsx, with Zip reported as indirect

Both are detected correctly now. Console output below 👍

Image

@kryptobi
kryptobi merged commit b05a4bb into main Aug 4, 2026
3 checks passed
@kryptobi
kryptobi deleted the fix/long-zip-files branch August 4, 2026 06:57
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.

3 participants