mirror of
https://github.com/Slug-Boi/cocommit.git
synced 2026-05-13 12:45:47 +00:00
fix: zip slip issue
This commit is contained in:
+5
-3
@@ -12,6 +12,7 @@ import (
|
|||||||
"path/filepath"
|
"path/filepath"
|
||||||
"regexp"
|
"regexp"
|
||||||
"runtime"
|
"runtime"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
@@ -171,9 +172,10 @@ func unzipper(dst string, r io.Reader) error {
|
|||||||
// the target location where the dir/file should be created
|
// the target location where the dir/file should be created
|
||||||
target := filepath.Join(dst, header.Name)
|
target := filepath.Join(dst, header.Name)
|
||||||
|
|
||||||
// the following switch could also be done using fi.Mode(), not sure if there
|
// ensure the target path is within the destination directory
|
||||||
// a benefit of using one vs. the other.
|
if !strings.HasPrefix(target, filepath.Clean(dst)+string(os.PathSeparator)) {
|
||||||
// fi := header.FileInfo()
|
return fmt.Errorf("illegal file path: %s", target)
|
||||||
|
}
|
||||||
|
|
||||||
// check the file type
|
// check the file type
|
||||||
switch header.Typeflag {
|
switch header.Typeflag {
|
||||||
|
|||||||
Reference in New Issue
Block a user