Skip to content

run check_eocd consistency check under ZIP_CHECKCONS - #546

Open
arshsmith1 wants to merge 1 commit into
nih-at:mainfrom
arshsmith1:checkcons-eocd-flags
Open

run check_eocd consistency check under ZIP_CHECKCONS#546
arshsmith1 wants to merge 1 commit into
nih-at:mainfrom
arshsmith1:checkcons-eocd-flags

Conversation

@arshsmith1

Copy link
Copy Markdown

check_eocd validates that the central directory ends exactly where the EOCD record begins, but only when ZIP_CHECKCONS is requested. It was passed za->flags instead of za->open_flags; bit 0x4 means ZIP_AFL_IS_TORRENTZIP in za->flags and ZIP_CHECKCONS in za->open_flags, and the torrentzip bit isn't set yet when the central directory is read, so the check never ran and an archive with a gap between the central directory and the EOCD was accepted even under ZIP_CHECKCONS. Pass za->open_flags here, the same way _zip_read_eocd64 was already corrected. The check also has to be skipped for Zip64 archives, where the central directory is followed by the Zip64 EOCD record and locator, so cd->offset + cd->size points before the 32-bit EOCD and the comparison would reject valid files.

check_eocd is gated on ZIP_CHECKCONS but was passed za->flags, where bit 0x4 is ZIP_AFL_IS_TORRENTZIP rather than ZIP_CHECKCONS, so the central-directory length check never ran. Pass za->open_flags as _zip_read_eocd64 already does, and skip it for Zip64 where the cdir is followed by the Zip64 EOCD record and locator.
@arshsmith1
arshsmith1 force-pushed the checkcons-eocd-flags branch from 9d9d8cf to 4a8b7c6 Compare July 20, 2026 06:38
@arshsmith1

Copy link
Copy Markdown
Author

Rebased onto current main to clear the AppVeyor failure. It was the DWORD_MAX undeclared error in zip_source_file_win32_named.c, not from this change: the branch was sitting on fdb9512, and 552e61f adds the intsafe.h include that fixes it. The patch itself is unchanged. Windows x64 builds clean and the full regress suite passes locally (186/186).

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