Skip to content

Commit

Permalink
fix for directory traversal
Browse files Browse the repository at this point in the history
  • Loading branch information
termie committed Jul 29, 2014
1 parent fdffe92 commit bcacb06
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions shutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,6 @@ func CopyTree(src, dst string, options *CopyTreeOptions) error {
return &AlreadyExistsError{dst}
}


entries, err := ioutil.ReadDir(src)
if err != nil {
return err
Expand All @@ -279,7 +278,6 @@ func CopyTree(src, dst string, options *CopyTreeOptions) error {
ignoredNames = options.Ignore(src, entries)
}


for _, entry := range entries {
if stringInSlice(entry.Name(), ignoredNames) {
continue
Expand Down Expand Up @@ -313,7 +311,10 @@ func CopyTree(src, dst string, options *CopyTreeOptions) error {
}
}
} else if entryFileInfo.IsDir() {
return CopyTree(srcPath, dstPath, options)
err = CopyTree(srcPath, dstPath, options)
if err != nil {
return err
}
} else {
_, err = options.CopyFunction(srcPath, dstPath, false)
if err != nil {
Expand Down

0 comments on commit bcacb06

Please sign in to comment.