Repository navigation
Conversation
vvoland
reviewed
Sep 30, 2026
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #123 +/- ##
==========================================
+ Coverage 65.48% 74.59% +9.11%
==========================================
Files 46 46
Lines 2393 2401 +8
==========================================
+ Hits 1567 1791 +224
- Misses 605 608 +3
+ Partials 221 2 -219 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Add DestinationRoot to TarOptions so callers can extract relative to an already-open os.Root. This preserves a caller-vetted directory identity when its pathname is renamed or replaced before extraction begins. Keep the existing behavior when DestinationRoot is unset. Treat dest as root-relative when it is set, retain caller ownership of the supplied root, and close only roots derived for nested destinations. Add coverage that replaces the original destination path after its root is opened and verifies that extraction still writes to the opened directory and does not close the caller-owned root. Signed-off-by: Remy Suen <remy.suen@docker.com> Co-authored-by: ChatGPT <noreply@openai.com>
rcjsuen
force-pushed
the
extraction-race-fix
branch
from
September 30, 2026 17:06
caf4765 to
ed8c1ed
Compare
Contributor
|
Left some suggestions: rcjsuen#1 |
Contributor
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
Add
TarOptions.DestinationRootso callers can extract relative to an already-open*os.Root.Existing callers are unaffected. When
DestinationRootis nil, extraction continues to opendestdirectly as it does today.Motivation
For the general case, passing a root is equivalent to allowing
Unpackto callos.OpenRoot(dest)itself. The distinction matters when a caller already has a vetted directory handle.If the caller converts that handle back into a pathname, the pathname can be renamed or replaced before
Unpackopens it. Extraction may then operate on a different directory from the one the caller selected. Passing the existingos.Rootpreserves that directory identity.This keeps authorization with the application while allowing
go-archiveto perform extraction through the boundary the application established.Behavior
When
DestinationRootis set,destis interpreted relative to it:This extracts into
outputbeneathroot. Passing.extracts directly beneath the supplied root.The ownership rules are:
DestinationRoot;destis closed by the library; andos.Root.DestinationRootapplies only to extraction. Archive creation is unchanged. No exported function signatures change.Testing
The regression test opens a destination root, renames its directory, and creates a replacement at the original pathname before extracting. It verifies that:
Validation performed:
The compression package's separate tests require the external
bzip2andxzexecutables, which were unavailable in the local environment.