crypto/ssh: Handle error in dial to avoid a goroutine leak
If the channel open request failed, a nil channel would be provided to DiscardRequests, which would never return. We return the error early to avoid this goroutine leak. Change-Id: I4c0e0a7698f7623c042f2a04941b8c50e8031d33 Reviewed-on: https://go-review.googlesource.com/13390 Reviewed-by: Dave Cheney <dave@cheney.net>
This commit is contained in:
committed by
Dave Cheney
parent
2f3083f616
commit
83f1503f77
@@ -355,6 +355,9 @@ func (c *Client) dial(laddr string, lport int, raddr string, rport int) (Channel
|
||||
lport: uint32(lport),
|
||||
}
|
||||
ch, in, err := c.OpenChannel("direct-tcpip", Marshal(&msg))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
go DiscardRequests(in)
|
||||
return ch, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user