Repository navigation
gh-154667: Validate zipfile timestamps consistently - #154740
Open
Taeknology wants to merge 3 commits into
Open
Taeknology wants to merge 3 commits into
Taeknology wants to merge 3 commits into
Conversation
Signed-off-by: Taeknology <20297177+Taeknology@users.noreply.github.com>
|
This PR is stale because it has been open for 90 days with no activity. |
Contributor
Author
|
@serhiy-storchaka, could you advise whether this focused scope is appropriate for a partial fix of #154667? It covers constructor bounds and filesystem timestamp handling in from_file(), without introducing a shared sanitizer or changing _for_archive(). PR #152452 addresses a related _for_archive() clamping issue. The follow-up preserves conversion errors for potentially valid ZIP timestamps rather than treating every localtime() failure as a ZIP-range overflow. Regression tests cover the simulated AIX 2038 limitation, timestamp boundaries, and extreme-value clamping. A review of the scope and error-handling approach would be appreciated. |
Include the upstream changes-builder fix for custom directives (pythongh-155100). Validation on the merged tree: - changes and HTML documentation builds passed. - ZIP-related tests: 1,036 run, 62 skipped, success. - ZipInfoTests reference-leak checks passed.
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.
Partially addresses #154667.
This PR is limited to
ZipInfo.__init__()andZipInfo.from_file():ValueError, matching the existing lower-bound validation.strict_timestamps=False, clamp filesystem timestamps whose converted year is outside 1980–2107, and clamp clearly out-of-range timestamps even whentime.localtime()cannot convert them.2107-12-31 23:59:58as the upper clamp result so it survives ZIP's two-second encoding unchanged. This is the clamp result, not a new maximum for every input: an ordinary2107-12-31 23:59:59input remains accepted and is encoded as 58 seconds, as before.This is not a shared sanitizer or a complete unification of timestamp handling. It does not change
ZipInfo._for_archive(), post-constructiondate_timeassignment, or normalize every strict-mode conversion exception toValueError. PR #152452 separately addresses non-strict clamping in_for_archive()forSOURCE_DATE_EPOCHand the system clock.Regression coverage includes simulated
OverflowErrorandOSErrorat the AIX/32-bit limits and near both ZIP boundaries, strict-mode exception propagation, extreme timestamp clamping, and ZIP round-tripping.Local validation
Using a debug build of this PR branch on Linux:
ZipInfoTests: 9 passed before the follow-up change../python -m unittest -v test.test_zipfile.test_core.ZipInfoTests: 10 passed, also checked underTZ=UTC0,TZ=EST5EDT, andTZ=JST-9../python -m test test_zipfile test_shutil test_zipapp test_zipimport -j4: 991 run, 62 skipped, success../python -m test test_zipfile -m '*ZipInfoTests*' -R 3:3: success; no reference leaks reported.The AIX failure path is simulated; these tests were not run on AIX. These local results do not represent a new CI run or validation against the latest upstream main.
zipfile: Inconsistent and insufficient date_time validation and handling acrossZipInfomethods #154667