From bcacb06fecaeec8dc42af03c87c6949f4a05c74c Mon Sep 17 00:00:00 2001 From: termie Date: Tue, 29 Jul 2014 14:59:57 -0700 Subject: [PATCH] fix for directory traversal --- shutil.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/shutil.go b/shutil.go index 8ebc437..09fcd38 100644 --- a/shutil.go +++ b/shutil.go @@ -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 @@ -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 @@ -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 {