Skip to content

Commit

Permalink
Merge pull request #2 from snoopysecurity/fix/santize-filename-paths
Browse files Browse the repository at this point in the history
fix: sanitize filepath names
  • Loading branch information
artdarek authored Mar 8, 2020
2 parents 33dc051 + 473b413 commit 4975cbe
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions unzip.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"path/filepath"
"io"
"fmt"
"strings"
)

type Unzip struct {
Expand Down Expand Up @@ -46,6 +47,9 @@ func (uz Unzip) Extract() error {
}()

path := filepath.Join(uz.Dest, f.Name)
if !strings.HasPrefix(path, filepath.Clean(uz.Dest)+string(os.PathSeparator)) {
return fmt.Errorf("%s: Illegal file path", path)
}

if f.FileInfo().IsDir() {
os.MkdirAll(path, f.Mode())
Expand Down

0 comments on commit 4975cbe

Please sign in to comment.