From 7f6e0bf4d06f819f27e78f3bf84b8aca56681fc5 Mon Sep 17 00:00:00 2001 From: Simone Gotti Date: Tue, 9 Dec 2014 17:33:38 +0100 Subject: [PATCH] The tar Header.Name (for example with gnu tar) can start with ./ (for example ./app and ./rootfs/). Use filepath.Clean and use the cleaned up name. This also makes the logic similar to ValidateLayout(). --- app-container/aci/layout.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/app-container/aci/layout.go b/app-container/aci/layout.go index 5e12671..0909490 100644 --- a/app-container/aci/layout.go +++ b/app-container/aci/layout.go @@ -97,20 +97,22 @@ Tar: default: return err } - switch hdr.Name { + name := filepath.Clean(hdr.Name) + switch name { + case ".": case "app": _, err := io.Copy(&im, tr) if err != nil { return err } imOK = true - case "rootfs/": + case "rootfs": if !hdr.FileInfo().IsDir() { return fmt.Errorf("rootfs is not a directory") } rfsOK = true default: - flist = append(flist, hdr.Name) + flist = append(flist, name) } } return validate(imOK, &im, rfsOK, flist)