diff options
Diffstat (limited to 'archive.go')
-rw-r--r-- | archive.go | 17 |
1 files changed, 17 insertions, 0 deletions
@@ -124,6 +124,8 @@ type TarCfg struct { Root string Chown bool Chmod bool + // Strict bails out when anything unexpected is encountered. + Strict bool } type TarExtracter struct { @@ -140,6 +142,21 @@ func (s *TarExtracter) FilterTar( ) error { target := path.Join(s.cfg.Root, header.Name) + if s.cfg.Strict { + if len(header.PAXRecords) > 0 { + return errors.Errorf( + "%s: contains unsupported PAXRecords, bailing out", + header.Name, + ) + } + if len(header.Xattrs) > 0 { + return errors.Errorf( + "%s: contains unsupported extended attributes, bailing out", + header.Name, + ) + } + } + var err error switch header.Typeflag { case tar.TypeBlock: |