Repository navigation
gh-159435: Fix tarfile offsets after PAX headers and GNU long names - #159532
Merged
ethanfurman merged 2 commits intoNov 5, 2026
Merged
Conversation
|
Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool. If this change has little impact on Python users, wait for a maintainer to apply the |
haampie
reviewed
Oct 28, 2026
Contributor
There was a problem hiding this comment.
This is correct, confirmed it with the tar-minefield test suite case F10: https://stoppels.ch/tar/F10.html. It does not affect the outcome of any of the other 80+ test cases.
ethanfurman
approved these changes
Oct 28, 2026
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.
gh-159435: Fix tarfile offsets after PAX headers and GNU long names
Fixes gh-159435.
When a PAX extended header supplies a
sizerecord and is followed by a GNUlong-name header,
TarInfo._proc_pax()calculated the next offset fromnext.offset. GNU long-name processing reuses that field for the specialheader, so the member header could be read again, causing duplicate members or
skipped members.
Capture
next.offset_databefore processing GNU sparse information and use itas the base for the PAX size offset calculation. This preserves the existing
GNU sparse 1.0 behavior while fixing the long-name case.
The change includes a regression test and a Library NEWS entry.
Tests
Lib/tarfile.pypasses for thePAX-size/GNU-long-name case and the existing GNU sparse PAX-size scenario.
python -m py_compile Lib/tarfile.py Lib/test/test_tarfile.pygit diff --check3.12 is installed, while current CPython main requires newer syntax/runtime
features.
AI assistance: OmniRush was used for investigation and implementation. The
contributor is responsible for reviewing and maintaining this change.