From 3257deae10b1309156ce645fad4fbdb64799a79b Mon Sep 17 00:00:00 2001 From: simon Date: Tue, 24 Oct 2000 09:55:45 +0000 Subject: [PATCH] SSH2 connections weren't closing cleanly after socket revamp. Fixed. git-svn-id: svn://svn.tartarus.org/sgt/putty@754 cda61777-01e9-0310-a592-d414129be87e --- ssh.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/ssh.c b/ssh.c index a7f41307..524a7504 100644 --- a/ssh.c +++ b/ssh.c @@ -993,6 +993,13 @@ static int ssh_receive(Socket s, int urgent, char *data, int len) { return 0; } ssh_gotdata (data, len); + if (ssh_state == SSH_STATE_CLOSED) { + if (s) { + sk_close(s); + s = NULL; + } + return 0; + } return 1; } @@ -1641,6 +1648,7 @@ static void ssh1_protocol(unsigned char *in, int inlen, int ispkt) { } else if (pktin.type == SSH1_MSG_DISCONNECT) { ssh_state = SSH_STATE_CLOSED; logevent("Received disconnect request"); + crReturnV; } else if (pktin.type == SSH1_SMSG_AGENT_OPEN) { /* Remote side is trying to open a channel to talk to our * agent. Give them back a local channel number. */ @@ -2402,6 +2410,7 @@ static void do_ssh2_authconn(unsigned char *in, int inlen, int ispkt) } else if (pktin.type == SSH2_MSG_DISCONNECT) { ssh_state = SSH_STATE_CLOSED; logevent("Received disconnect message"); + crReturnV; } else if (pktin.type == SSH2_MSG_CHANNEL_REQUEST) { continue; /* exit status et al; ignore (FIXME?) */ } else if (pktin.type == SSH2_MSG_CHANNEL_EOF) { @@ -2419,8 +2428,7 @@ static void do_ssh2_authconn(unsigned char *in, int inlen, int ispkt) ssh2_pkt_init(SSH2_MSG_DISCONNECT); ssh2_pkt_send(); ssh_state = SSH_STATE_CLOSED; - sk_close(s); - s = NULL; + crReturnV; } continue; /* remote sends close; ignore (FIXME) */ } else if (pktin.type == SSH2_MSG_CHANNEL_WINDOW_ADJUST) { -- 2.11.0