Repository navigation
Clear stale path bytes in install_only tar headers - #1345
Open
RaphaelFakhri wants to merge 1 commit into
Open
RaphaelFakhri wants to merge 1 commit into
RaphaelFakhri wants to merge 1 commit into
Conversation
The install_only conversion rewrites each entry path from python/install/... to python/... with tar::Header::set_path. set_path does not clear the name field past the new NUL terminator, and does not clear the ustar prefix when the new path fits in the name field. Each header kept the tail of the original path after the NUL, which some tar readers include in the entry name. Clear the name and prefix fields before setting the new path. Fixes astral-sh#686
This branch has not been deployed
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.
Summary
convert_to_install_onlyrewrites each entry path frompython/install/...topython/...withtar::Header::set_path.set_pathwrites the new path and a NUL terminator but leaves the rest of the 100-bytenamefield unchanged. It also leaves the ustarprefixfield unchanged when the new path fits inname. Each rewritten header kept the tail of the original, longer path after the NUL.The tar format allows this, but some readers include those bytes in the entry name. For example, older
System.Formats.Tarreleases in .NET readpython/bin/idle3.13aspython/bin/idle3.13\0dle3.13(dotnet/runtime#117331). Incpython-3.13.16+20261013-x86_64-unknown-linux-gnu-install_only.tar.gz, 4523 of 4526 headers have non-zero bytes after the terminator, for examplepython/bin/pip\0bin/pip.This change clears
name, andprefixfor ustar headers, before callingset_path. Theinstall_only_strippedarchives are produced from theinstall_onlyarchive without changing paths, so they are fixed too.Fixes #686
Test plan
release::tests::install_only_clears_stale_header_path_bytes. The test builds a small full archive, converts it, and checks the rawnameandprefixbytes of every output header. It covers a short path (bin/idle3.13) and a path stored with a ustar prefix in the input that fits innameafter conversion.namecheck. With only thenameclearing, it fails on theprefixcheck. With the full fix,cargo test --bin pythonbuildpasses (4 passed).cargo fmtandcargo clippy --bin pythonbuild --testsreport nothing new.