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.
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