From 585e6572bd9140074a094d1a60388b935b63f270 Mon Sep 17 00:00:00 2001 From: Josh Soref Date: Tue, 23 Feb 2021 13:34:47 -0500 Subject: [PATCH] chore: Fail fast for parts[0] Signed-off-by: Josh Soref --- pkg/chart/loader/archive.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/pkg/chart/loader/archive.go b/pkg/chart/loader/archive.go index 8b38cb89f..d13146595 100644 --- a/pkg/chart/loader/archive.go +++ b/pkg/chart/loader/archive.go @@ -139,6 +139,11 @@ func LoadArchiveFiles(in io.Reader) ([]*BufferedFile, error) { } parts := strings.Split(hd.Name, delimiter) + + if parts[0] == "Chart.yaml" { + return nil, errors.New("chart yaml not in base directory") + } + n := strings.Join(parts[1:], delimiter) // Normalize the path to the / delimiter @@ -165,10 +170,6 @@ func LoadArchiveFiles(in io.Reader) ([]*BufferedFile, error) { return nil, errors.New("chart contains illegally named files") } - if parts[0] == "Chart.yaml" { - return nil, errors.New("chart yaml not in base directory") - } - if _, err := io.Copy(b, tr); err != nil { return nil, err }