Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ignore pax global header in tar extract #1036

Merged
merged 2 commits into from
Mar 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions archive/extract.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@ func Extract(tr TarReader) error {
if err := createSymlink(hdr); err != nil {
return errors.Wrapf(err, "failed to create symlink %q with target %q", hdr.Name, hdr.Linkname)
}
case tar.TypeXGlobalHeader:
// ignore PAX Global Extended Headers
continue
default:
return fmt.Errorf("unknown file type in tar %d", hdr.Typeflag)
}
Expand Down
5 changes: 5 additions & 0 deletions archive/extract_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,11 @@ func newFakeTarReader(t *testing.T) (*archive.NormalizingTarReader, string) {
}

func pushHeaders(ftr *fakeTarReader) {
ftr.pushHeader(&tar.Header{
Name: "pax_global_header",
Typeflag: tar.TypeXGlobalHeader,
Mode: int64(0),
})
ftr.pushHeader(&tar.Header{
Name: "root/symlinkdir",
Typeflag: tar.TypeSymlink,
Expand Down