Skip to content

Commit

Permalink
Skip global PAXHeaders
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
tempusfrangit committed Apr 27, 2024
1 parent 295522b commit bc57999
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions pkg/extract/tar.go
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down

0 comments on commit bc57999

Please sign in to comment.