Merge pull request #21726 from aaronlehmann/tarsum-filename-normalization

Fix build cache false positives when build context tar contains unnormalized paths
This commit is contained in:
Tõnis Tiigi 2016-04-15 09:45:26 -07:00
commit c35a0da252

View file

@ -28,6 +28,7 @@ import (
"fmt" "fmt"
"hash" "hash"
"io" "io"
"path"
"strings" "strings"
) )
@ -235,7 +236,7 @@ func (ts *tarSum) Read(buf []byte) (int, error) {
} }
return n, err return n, err
} }
ts.currentFile = strings.TrimSuffix(strings.TrimPrefix(currentHeader.Name, "./"), "/") ts.currentFile = path.Clean(currentHeader.Name)
if err := ts.encodeHeader(currentHeader); err != nil { if err := ts.encodeHeader(currentHeader); err != nil {
return 0, err return 0, err
} }