go.crypto/ssh: never send more data than maxpacket

RFC 4254 s5.2 is clear that a client must never send a data
packet larger than the value of maximum packet supplied by the
remote side during channel setup. The client was not honoring
this value, in fact it wasn't even recording it.

Thanks to Albert Strasheim for the bug report.

R=agl, fullung
CC=golang-dev
https://golang.org/cl/6448128
This commit is contained in:
Dave Cheney
2012-08-09 10:22:00 +10:00
parent 71484c7202
commit f4749cba32
4 changed files with 49 additions and 14 deletions
+8 -7
View File
@@ -569,14 +569,15 @@ func (s *ServerConn) Accept() (Channel, error) {
conn: s,
remoteId: msg.PeersId,
remoteWin: window{Cond: newCond()},
// TODO(dfc) assert this param is < 2^31.
maxPacketSize: msg.MaxPacketSize,
},
chanType: msg.ChanType,
maxPacketSize: msg.MaxPacketSize,
extraData: msg.TypeSpecificData,
myWindow: defaultWindowSize,
serverConn: s,
cond: newCond(),
pendingData: make([]byte, defaultWindowSize),
chanType: msg.ChanType,
extraData: msg.TypeSpecificData,
myWindow: defaultWindowSize,
serverConn: s,
cond: newCond(),
pendingData: make([]byte, defaultWindowSize),
}
c.remoteWin.add(msg.PeersWindow)
s.lock.Lock()