diff options
| author | Josh Bleecher Snyder <josharian@gmail.com> | 2016-05-30 12:57:20 -0700 |
|---|---|---|
| committer | Josh Bleecher Snyder <josharian@gmail.com> | 2016-05-31 00:11:32 +0000 |
| commit | d2c92f8453cab8d042b794c8ce398f6ff8e6f650 (patch) | |
| tree | eb6b91ee43b4ca3270d95479e09a4dbc5aaca3ed /src/path/filepath | |
| parent | 81a8f1a7946c28eaa9c187b7aaa349020b7a9ba4 (diff) | |
| download | go-d2c92f8453cab8d042b794c8ce398f6ff8e6f650.tar.xz | |
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>
Diffstat (limited to 'src/path/filepath')
| -rw-r--r-- | src/path/filepath/match.go | 5 | ||||
| -rw-r--r-- | src/path/filepath/match_test.go | 6 |
2 files changed, 11 insertions, 0 deletions
diff --git a/src/path/filepath/match.go b/src/path/filepath/match.go index 2adb0c7490..9fa68f578d 100644 --- a/src/path/filepath/match.go +++ b/src/path/filepath/match.go @@ -250,6 +250,11 @@ func Glob(pattern string) (matches []string, err error) { return glob(dir, file, nil) } + // Prevent infinite recursion. See issue 15879. + if dir == pattern { + return nil, ErrBadPattern + } + var m []string m, err = Glob(dir) if err != nil { diff --git a/src/path/filepath/match_test.go b/src/path/filepath/match_test.go index 8dcfa5972e..6b068c778e 100644 --- a/src/path/filepath/match_test.go +++ b/src/path/filepath/match_test.go @@ -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 { path, dest string brokenLink bool |
