go.crypto/ssh: only offset channel IDs when debugMux is
set.
Otherwise, the package leaks data about total number of
connections established through its channel IDs.
R=agl, jpsugar
CC=golang-codereviews
https://golang.org/cl/87280043
diff --git a/ssh/mux.go b/ssh/mux.go
index 5af7c16..321880a 100644
--- a/ssh/mux.go
+++ b/ssh/mux.go
@@ -99,7 +99,8 @@
err error
}
-// Each new chanList instantiation has a different offset.
+// When debugging, each new chanList instantiation has a different
+// offset.
var globalOff uint32
func (m *mux) Wait() error {
@@ -120,7 +121,10 @@
incomingRequests: make(chan *Request, 16),
errCond: newCond(),
}
- m.chanList.offset = atomic.AddUint32(&globalOff, 1)
+ if debugMux {
+ m.chanList.offset = atomic.AddUint32(&globalOff, 1)
+ }
+
go m.loop()
return m
}