run check_eocd consistency check under ZIP_CHECKCONS#546
Open
arshsmith1 wants to merge 1 commit into
Open
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.