Skip to content

Commit 61415be

Browse files
findleyrgopherbot
authored andcommitted
gopls/internal/cache: guard against malformed paths in port.matches
It's possible that we may encounter the path inconsistency of golang/go#67288 due to unclean or relative paths. Guard against this with a new bug report. For golang/go#67288 Change-Id: I37ac1f74334bcb9e955d75e436f74398c73f0acb Reviewed-on: https://go-review.googlesource.com/c/tools/+/626015 Reviewed-by: Alan Donovan <[email protected]> Auto-Submit: Robert Findley <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]>
1 parent 9a89d3a commit 61415be

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

gopls/internal/cache/port.go

+5
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,11 @@ var (
141141
func (p port) matches(path string, content []byte) bool {
142142
ctxt := build.Default // make a copy
143143
ctxt.UseAllFiles = false
144+
path = filepath.Clean(path)
145+
if !filepath.IsAbs(path) {
146+
bug.Reportf("non-abs file path %q", path)
147+
return false // fail closed
148+
}
144149
dir, name := filepath.Split(path)
145150

146151
// The only virtualized operation called by MatchFile is OpenFile.

0 commit comments

Comments
 (0)