Skip to content

Commit

Permalink
Merge pull request #86 from HsuJv/patch_85
Browse files Browse the repository at this point in the history
Bugfix for #85
  • Loading branch information
HsuJv authored Nov 15, 2023
2 parents 9f3528d + ac9098a commit 7d23c5e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/config/version.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ impl SshVersion {
S: Read,
{
let buf = read_version(stream, timeout)?;
if &buf[0..4] != SSH_MAGIC {
if buf.len() < 4 || &buf[0..4] != SSH_MAGIC {
error!("SSH version magic doesn't match");
error!("Probably not an ssh server");
}
Expand Down
5 changes: 3 additions & 2 deletions src/session/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,15 @@ where
.connect(),
SessionState::Version(mut config, mut stream) => {
info!("start for version negotiation.");
// Send Client version
config.ver.send_our_version(&mut stream)?;

// Receive the server version
config
.ver
.read_server_version(&mut stream, config.timeout)?;
// Version validate
config.ver.validate()?;
// Send Client version
config.ver.send_our_version(&mut stream)?;

// from now on
// each step of the interaction is subject to the ssh constraints on the packet
Expand Down

0 comments on commit 7d23c5e

Please sign in to comment.