]> Cypherpunks repositories - gostls13.git/commitdiff
path/filepath: prevent infinite recursion on Windows on UNC input
authorJosh Bleecher Snyder <josharian@gmail.com>
Mon, 30 May 2016 19:57:20 +0000 (12:57 -0700)
committerJosh Bleecher Snyder <josharian@gmail.com>
Tue, 31 May 2016 00:11:32 +0000 (00:11 +0000)
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>
src/path/filepath/match.go
src/path/filepath/match_test.go

index 2adb0c7490821e75e6fd4988bdad8c80ef506c7b..9fa68f578d00b829db9240cd2540832c66b428da 100644 (file)
@@ -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 {
index 8dcfa5972e551f59ca092453653571a75045d0dd..6b068c778e959cac6a07529d323d9a59a02c59d0 100644 (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 {
        path, dest string
        brokenLink bool