Explorar o código

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>
Eric Garrido %!s(int64=10) %!d(string=hai) anos
pai
achega
83f1503f77
Modificáronse 1 ficheiros con 3 adicións e 0 borrados
  1. 3 0
      ssh/tcpip.go

+ 3 - 0
ssh/tcpip.go

@@ -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
 }