SSH2 connections weren't closing cleanly after socket revamp. Fixed.
authorsimon <simon@cda61777-01e9-0310-a592-d414129be87e>
Tue, 24 Oct 2000 09:55:45 +0000 (09:55 +0000)
committersimon <simon@cda61777-01e9-0310-a592-d414129be87e>
Tue, 24 Oct 2000 09:55:45 +0000 (09:55 +0000)
git-svn-id: svn://svn.tartarus.org/sgt/putty@754 cda61777-01e9-0310-a592-d414129be87e

ssh.c

diff --git a/ssh.c b/ssh.c
index a7f4130..524a750 100644 (file)
--- 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);
        return 0;
     }
     ssh_gotdata (data, len);
+    if (ssh_state == SSH_STATE_CLOSED) {
+        if (s) {
+            sk_close(s);
+            s = NULL;
+        }
+        return 0;
+    }
     return 1;
 }
 
     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");
            } 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. */
             } 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");
            } 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) {
            } 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;
                     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) {
                 }
                 continue;              /* remote sends close; ignore (FIXME) */
            } else if (pktin.type == SSH2_MSG_CHANNEL_WINDOW_ADJUST) {