1
0
mirror of https://github.com/golang/go synced 2024-11-12 05:40:22 -07:00

path/filepath: prevent infinite recursion on Windows on UNC input

This is a minimal fix to prevent this and
other possible future infinite recursion.
We can put in a proper fix for UNC in Go 1.8.

Updates #15879

Change-Id: I3653cf5891bab8511adf66fa3c1a1d8912d1a293
Reviewed-on: https://go-review.googlesource.com/23572
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Andrew Gerrand <adg@golang.org>
This commit is contained in:
Josh Bleecher Snyder 2016-05-30 12:57:20 -07:00
parent 81a8f1a794
commit d2c92f8453
2 changed files with 11 additions and 0 deletions

View File

@ -250,6 +250,11 @@ func Glob(pattern string) (matches []string, err error) {
return glob(dir, file, nil) return glob(dir, file, nil)
} }
// Prevent infinite recursion. See issue 15879.
if dir == pattern {
return nil, ErrBadPattern
}
var m []string var m []string
m, err = Glob(dir) m, err = Glob(dir)
if err != nil { if err != nil {

View File

@ -159,6 +159,12 @@ func TestGlobError(t *testing.T) {
} }
} }
func TestGlobUNC(t *testing.T) {
// Just make sure this runs without crashing for now.
// See issue 15879.
Glob(`\\?\C:\*`)
}
var globSymlinkTests = []struct { var globSymlinkTests = []struct {
path, dest string path, dest string
brokenLink bool brokenLink bool