Fixing issue with PAX headers in plugin archive

PAX Headers can be added by some systems that create archives. Helm
should ignore them when extracting.

There are two PAX headers. One is global and the other is not. Both
are ignored. The test adds only the PAX global header because the
Go tar package is unable to write the header that is not global.

Closes #8084

Signed-off-by: Matt Farina <matt@mattfarina.com>
pull/8086/head
Matt Farina 5 years ago
parent 1d4eb7440d
commit 09a1cb2ce6
No known key found for this signature in database
GPG Key ID: 9436E80BFBA46909

@ -188,6 +188,9 @@ func (g *TarGzExtractor) Extract(buffer *bytes.Buffer, targetDir string) error {
return err
}
outFile.Close()
// We don't want to process these extension header files.
case tar.TypeXGlobalHeader, tar.TypeXHeader:
continue
default:
return errors.Errorf("unknown type: %b in %s", header.Typeflag, header.Name)
}

@ -222,6 +222,19 @@ func TestExtract(t *testing.T) {
t.Fatal(err)
}
}
// Add pax global headers. This should be ignored.
// Note the PAX header that isn't global cannot be written using WriteHeader.
// Details are in the internal Go function for the tar packaged named
// allowedFormats. For a TypeXHeader it will return a message stating
// "cannot manually encode TypeXHeader, TypeGNULongName, or TypeGNULongLink headers"
if err := tw.WriteHeader(&tar.Header{
Name: "pax_global_header",
Typeflag: tar.TypeXGlobalHeader,
}); err != nil {
t.Fatal(err)
}
if err := tw.Close(); err != nil {
t.Fatal(err)
}

Loading…
Cancel
Save