From ff790796728ed74ff29cded408622117ebf0e64f Mon Sep 17 00:00:00 2001 From: Wez Furlong Date: Tue, 30 Jul 2019 11:17:34 -0700 Subject: improve handshake error reporting on windows I'm hitting a kex protocol error when talking from windows->ubuntu 19 and that wasn't getting reported as an error on the client side because the `rc` function only emits an error if one has been recorded against the session object, despite being reported via the parameter. I think it's worth revisiting this more broadly, but for now, let's report this error in the handshake case. --- src/session.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/session.rs b/src/session.rs index 8fa188e..3ae3473 100644 --- a/src/session.rs +++ b/src/session.rs @@ -177,7 +177,15 @@ impl Session { } unsafe { - self.rc(handshake(self.inner.raw, &stream))?; + let res = handshake(self.inner.raw, &stream); + self.rc(res)?; + if res < 0 { + // There are some kex related errors that don't set the + // last error on the session object and that will not cause + // the `rc` function to emit an error. + // Let's ensure that we indicate an error in this situation. + return Err(Error::new(res, "Error during handshake")); + } *self.inner.tcp.borrow_mut() = Some(stream); Ok(()) } -- cgit v1.2.3