Skip to content

Commit

Permalink
Clean filepaths in mutate.Extract (#1106)
Browse files Browse the repository at this point in the history
When flattening a filesystem, we have to clean filepaths so that
we don't have duplicate filepaths in the resulting image, as per the OCI
spec (and tar-split throwing a fit if we don't do this).
  • Loading branch information
jonjohnsonjr committed Aug 13, 2021
1 parent bea59b9 commit f9a1886
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions pkg/v1/mutate/mutate.go
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,10 @@ func extract(img v1.Image, w io.Writer) error {
return fmt.Errorf("reading tar: %v", err)
}

// Some tools prepend everything with "./", so if we don't Clean the
// name, we may have duplicate entries, which angers tar-split.
header.Name = filepath.Clean(header.Name)

basename := filepath.Base(header.Name)
dirname := filepath.Dir(header.Name)
tombstone := strings.HasPrefix(basename, whiteoutPrefix)
Expand Down

0 comments on commit f9a1886

Please sign in to comment.