ssh: cosmetic cleanups
These are the cosmetic cleanups from the bits of code that I rereviewed. 1) stringLength now takes a int; the length of the string. Too many callers were allocating with stringLength([]byte(s)) and stringLength only needs to call len(). 2) agent.go now has sendAndReceive to remove logic that was duplicated. 3) We now reject negative DH values 4) We now reject empty packets rather than crashing. R=dave, jonathan.mark.pittman CC=golang-dev https://golang.org/cl/6061052
This commit is contained in:
+8
-9
@@ -56,7 +56,7 @@ type ChannelRequest struct {
|
||||
}
|
||||
|
||||
func (c ChannelRequest) Error() string {
|
||||
return "channel request received"
|
||||
return "ssh: channel request received"
|
||||
}
|
||||
|
||||
// RejectionReason is an enumeration used when rejecting channel creation
|
||||
@@ -255,7 +255,7 @@ func (c *channel) Read(data []byte) (n int, err error) {
|
||||
}
|
||||
|
||||
if c.length > 0 {
|
||||
tail := min(c.head + c.length, len(c.pendingData))
|
||||
tail := min(c.head+c.length, len(c.pendingData))
|
||||
n = copy(data, c.pendingData[c.head:tail])
|
||||
c.head += n
|
||||
c.length -= n
|
||||
@@ -374,18 +374,17 @@ func (c *channel) AckRequest(ok bool) error {
|
||||
return c.serverConn.err
|
||||
}
|
||||
|
||||
if ok {
|
||||
ack := channelRequestSuccessMsg{
|
||||
PeersId: c.theirId,
|
||||
}
|
||||
return c.serverConn.writePacket(marshal(msgChannelSuccess, ack))
|
||||
} else {
|
||||
if !ok {
|
||||
ack := channelRequestFailureMsg{
|
||||
PeersId: c.theirId,
|
||||
}
|
||||
return c.serverConn.writePacket(marshal(msgChannelFailure, ack))
|
||||
}
|
||||
panic("unreachable")
|
||||
|
||||
ack := channelRequestSuccessMsg{
|
||||
PeersId: c.theirId,
|
||||
}
|
||||
return c.serverConn.writePacket(marshal(msgChannelSuccess, ack))
|
||||
}
|
||||
|
||||
func (c *channel) ChannelType() string {
|
||||
|
||||
Reference in New Issue
Block a user