summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWez Furlong <wez@wezfurlong.org>2019-07-30 11:17:34 -0700
committerWez Furlong <wez@wezfurlong.org>2019-07-30 11:17:34 -0700
commitff790796728ed74ff29cded408622117ebf0e64f (patch)
tree61f17d19331819c2c48718abc57e6e2fd1af5946
parentb631167fe0c308ca02e8269da212c436d8867a10 (diff)
downloadssh2-rs-ff790796728ed74ff29cded408622117ebf0e64f.zip
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.
-rw-r--r--src/session.rs10
1 files changed, 9 insertions, 1 deletions
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(())
}