Skip to content

Commit 20a6137

Browse files
committed
more closely match default tar errors (GNU + BSD binaries)
1 parent c528cc7 commit 20a6137

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

extractor.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,12 @@ func (te *Extractor) Sanitize(toggle bool) {
104104

105105
// outputPath returns the path at which to place tarPath
106106
func (te *Extractor) outputPath(tarPath string) (outPath string, err error) {
107-
elems := strings.Split(tarPath, "/") // break into elems
107+
elems := strings.Split(tarPath, "/") // break into elems
108+
for _, e := range elems {
109+
if e == ".." {
110+
return "", fmt.Errorf("%s : path contains '..'", tarPath)
111+
}
112+
}
108113
elems = elems[1:] // remove original root
109114
outPath = strings.Join(elems, "/") // join elems
110115
outPath = gopath.Join(te.Path, outPath) // rebase on to extraction target root

0 commit comments

Comments
 (0)