From bc5799931574fa0342339a33aa175901f7600b6b Mon Sep 17 00:00:00 2001 From: Morgan Fainberg Date: Sat, 27 Apr 2024 13:03:02 -0700 Subject: [PATCH] Skip global PAXHeaders Global PAX Headers are a meta-header that applies to subsequent files. However, in most cases these values are 100% ignorable as the underlying archive/tar handles merging things. However, the global header stat is not persisted across headers (as per the spec); notably this is largely "OK" as most values within the global header are not commonly used or relevant (i.e. size is unlikely to be relevant as that is file by file and not global). We can always add futher PAX Header support if needed, but the reality is pget is highly optimized for it's use case and doesn't go too far out of it's way for cases that aren't relevant. --- pkg/extract/tar.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pkg/extract/tar.go b/pkg/extract/tar.go index 89cfaf7..a4b7def 100644 --- a/pkg/extract/tar.go +++ b/pkg/extract/tar.go @@ -64,6 +64,11 @@ func TarFile(r io.Reader, destDir string, overwrite bool) error { } switch header.Typeflag { + case tar.TypeXGlobalHeader: + // This is a global pax header, which we can skip as it's mostly handled by the underlying implementation + // NOTE: the global header is not persisted across subsequent calls to Next() and therefore could indicate + // that we are processing a tar file in an unintended manner. This is a limitation of archive/tar. + continue case tar.TypeDir: logger.Debug(). Str("target", target).