From 0b5e3c60b4763f8c1afa7d423e4cd82246eeb23b Mon Sep 17 00:00:00 2001 From: Rob Dimsdale-Zucker Date: Mon, 11 Sep 2023 19:07:36 +0000 Subject: [PATCH] Strip off preceding '.' from layer header names if present. - Some images (e.g. VMware photon) have file headers in the format ./etc/... rather than /etc/... --- internal/ihop/image.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/internal/ihop/image.go b/internal/ihop/image.go index 44c664a..242c8a3 100644 --- a/internal/ihop/image.go +++ b/internal/ihop/image.go @@ -42,7 +42,12 @@ func findFile(image v1.Image, filepath string) (*tar.Header, io.Reader, error) { return nil, nil, err } - if strings.TrimPrefix(hdr.Name, "/") == strings.TrimPrefix(filepath, "/") { + // Some images have filepaths with a preceding '.' + // e.g. './etc/...' instead of '/etc/...' + // Strip it off if it exists + headerName := strings.TrimPrefix(hdr.Name, ".") + + if strings.TrimPrefix(headerName, "/") == strings.TrimPrefix(filepath, "/") { found = true if hdr.Typeflag == tar.TypeSymlink { header, reader, err = findFile(image, path.Join(path.Dir(filepath), hdr.Linkname))