Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

gh-121171: Fix zip64 extract version in local headers#121177

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
danifus wants to merge3 commits intopython:main
base:main
Choose a base branch
Loading
fromdanifus:repro_121171

Conversation

danifus
Copy link
Contributor

@danifusdanifus commentedJun 30, 2024
edited
Loading

Fix: Wrong extract version set in local headers for files located beyond zip64 limit#121171

If the total archive size or file count in the archive exceeded thezip64 thresholds, the zip64 minimum extract version was not beingwritten to the local header. The central header had the correct version
@danifusdanifus changed the titlegh-121171: Add failing test for reproducinggh-121171: Fix zip64 extract version in local headersJun 30, 2024
@danifusdanifus marked this pull request as ready for reviewJune 30, 2024 11:34
@danifusdanifus closed thisJul 1, 2024
@danifusdanifus reopened thisJul 1, 2024
@danifus
Copy link
ContributorAuthor

@jaraco are you able to do a review on this bug fix? Thanks!

@@ -1733,6 +1733,12 @@ def _open_to_write(self, zinfo, force_zip64=False):
if self._seekable:
self.fp.seek(self.start_dir)
zinfo.header_offset = self.fp.tell()
# exceptions raised in _writecheck if _allowZip64 is False
zip64 = (
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

you could|= here and save a line

# exceptions raised in _writecheck if _allowZip64 is False
zip64 = (
zip64
or zinfo.header_offset > ZIP64_LIMIT
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I explicitly approve of the following line being>= because it makes having the extra unambiguous, you might make this line also>= for the same reason. I think the functionality lost by being able to produce this precise file with_allowZip64=False is minimal.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I don't know if this was copypasted from the central directory logic; it would be nice if they match as this is fixing the inconsistency.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Yeah, I copied the conditionals from:

iflen(self.filelist)>=ZIP_FILECOUNT_LIMIT:
requires_zip64="Files count"
elifzinfo.file_size>ZIP64_LIMIT:
requires_zip64="Filesize"
elifzinfo.header_offset>ZIP64_LIMIT:
requires_zip64="Zipfile size"
ifrequires_zip64:
raiseLargeZipFile(requires_zip64+
" would require ZIP64 extensions")

(filesize is handled a few lines above the added code)

This is the line with the different operator that existed before this PR:

ifcentDirCount>ZIP_FILECOUNT_LIMIT:

Good catch. I'd be happy either way as long as we use the same one everywhere.

GivenZIP_FILECOUNT_LIMIT = (1 << 16) - 1 (1 less than the actual limit of0xFFFF) I would be inclined to change if to> to be consistent with how all the other checks againstZIP64_LIMIT andZIP_FILECOUNT_LIMIT are written (we also get to cram one more file in :p) but I don't feel that strongly about it :)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I don't follow the rest of the logic,

>>> hex((1<<16) - 1)'0xffff'

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

ah whoops.(1<<16) - 1 is not one less than the limit - it is the limit :p

I still have a small preference that it should be changed to> so that we can store the maximum possible files allowed without the zip64 extra field and for consistency with all the other checks againstZIP64_LIMIT andZIP_FILECOUNT_LIMITZIP_MAX_COMMENT that use>.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@thatchthatchthatch left review comments

@AkasurdeAkasurdeAkasurde approved these changes

@cmaloneycmaloneycmaloney approved these changes

Assignees
No one assigned
Labels
awaiting core reviewtestsTests in the Lib/test dir
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

4 participants
@danifus@thatch@Akasurde@cmaloney

[8]ページ先頭

©2009-2025 Movatter.jp