From 058f0eec529666ecacd81b63aba586dad0b34a6b Mon Sep 17 00:00:00 2001 From: Han-Wen Nienhuys Date: Mon, 14 Apr 2014 09:23:18 -0700 Subject: [PATCH] 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 --- ssh/mux.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) 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 @@ type mux struct { 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 @@ func newMux(p packetConn) *mux { 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 }