mirror of
https://github.com/octoleo/syncthing.git
synced 2025-01-23 07:08:24 +00:00
lib/osutil: Prevent infinite Glob recursion (fixes #3577)
Skip-check: authors GitHub-Pull-Request: https://github.com/syncthing/syncthing/pull/3665
This commit is contained in:
parent
d203dd4770
commit
05c37e58c1
@ -26,7 +26,7 @@ func Glob(pattern string) (matches []string, err error) {
|
|||||||
return []string{pattern}, nil
|
return []string{pattern}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
dir, file := filepath.Split(pattern)
|
dir, file := filepath.Split(filepath.Clean(pattern))
|
||||||
switch dir {
|
switch dir {
|
||||||
case "":
|
case "":
|
||||||
dir = "."
|
dir = "."
|
||||||
|
29
lib/osutil/glob_windows_test.go
Normal file
29
lib/osutil/glob_windows_test.go
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
// Copyright (C) 2014 The Syncthing Authors.
|
||||||
|
//
|
||||||
|
// This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
// License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||||
|
// You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
|
|
||||||
|
// +build windows
|
||||||
|
|
||||||
|
package osutil_test
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/syncthing/syncthing/lib/osutil"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestGlob(t *testing.T) {
|
||||||
|
testcases := []string{
|
||||||
|
`C:\*`,
|
||||||
|
`\\?\C:\*`,
|
||||||
|
`\\?\C:\Users`,
|
||||||
|
`\\?\\\?\C:\Users`,
|
||||||
|
}
|
||||||
|
for _, tc := range testcases {
|
||||||
|
if _, err := osutil.Glob(tc); err != nil {
|
||||||
|
t.Fatalf("pattern %s failed: %v", tc, err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user