@@ -19,12 +19,13 @@ package util
19
19
import (
20
20
"archive/tar"
21
21
"fmt"
22
- "github.com/pkg/errors"
23
- "github.com/sirupsen/logrus"
24
22
"io"
25
23
"os"
26
24
"path/filepath"
27
25
"strings"
26
+
27
+ "github.com/pkg/errors"
28
+ "github.com/sirupsen/logrus"
28
29
)
29
30
30
31
// Map of target:linkname
@@ -48,7 +49,7 @@ func unpackTar(tr *tar.Reader, path string, whitelist []string) error {
48
49
return err
49
50
}
50
51
if strings .Contains (header .Name , ".wh." ) {
51
- rmPath := filepath .Join (path , header .Name )
52
+ rmPath := filepath .Clean ( filepath . Join (path , header .Name ) )
52
53
// Remove the .wh file if it was extracted.
53
54
if _ , err := os .Stat (rmPath ); ! os .IsNotExist (err ) {
54
55
if err := os .Remove (rmPath ); err != nil {
@@ -63,7 +64,7 @@ func unpackTar(tr *tar.Reader, path string, whitelist []string) error {
63
64
}
64
65
continue
65
66
}
66
- target := filepath .Join (path , header .Name )
67
+ target := filepath .Clean ( filepath . Join (path , header .Name ) )
67
68
// Make sure the target isn't part of the whitelist
68
69
if checkWhitelist (target , whitelist ) {
69
70
continue
@@ -143,7 +144,7 @@ func unpackTar(tr *tar.Reader, path string, whitelist []string) error {
143
144
logrus .Errorf ("Failed to create symlink between %s and %s: %s" , header .Linkname , target , err )
144
145
}
145
146
case tar .TypeLink :
146
- linkname := filepath .Join (path , header .Linkname )
147
+ linkname := filepath .Clean ( filepath . Join (path , header .Linkname ) )
147
148
// Check if the linkname already exists
148
149
if _ , err := os .Stat (linkname ); ! os .IsNotExist (err ) {
149
150
// If it exists, create the hard link
0 commit comments