Support multiple anchor name types now that Jacob has enhanced
[u/mdw/putty] / ssh.c
diff --git a/ssh.c b/ssh.c
index 72f142f..e202dbb 100644 (file)
--- a/ssh.c
+++ b/ssh.c
@@ -2383,7 +2383,8 @@ static void ssh_process_queued_incoming_data(Ssh ssh)
 
 static void ssh_set_frozen(Ssh ssh, int frozen)
 {
-    sk_set_frozen(ssh->s, frozen);
+    if (ssh->s)
+       sk_set_frozen(ssh->s, frozen);
     ssh->frozen = frozen;
 }
 
@@ -2516,6 +2517,9 @@ static int ssh_closing(Plug plug, const char *error_msg, int error_code,
         error_msg = "Server unexpectedly closed network connection";
     }
 
+    if (need_notify)
+        notify_remote_exit(ssh->frontend);
+
     if (error_msg) {
        /* A socket error has occurred. */
        logevent(error_msg);
@@ -2523,8 +2527,6 @@ static int ssh_closing(Plug plug, const char *error_msg, int error_code,
     } else {
         logevent("Server closed network connection");
     }
-    if (need_notify)
-        notify_remote_exit(ssh->frontend);
     return 0;
 }
 
@@ -2932,6 +2934,7 @@ static int do_ssh1_login(Ssh ssh, unsigned char *in, int inlen,
         if (s->dlgret == 0) {
             ssh->close_expected = TRUE;
             ssh_closing((Plug)ssh, NULL, 0, 0);
+           crStop(0);
         }
     }
 
@@ -3012,6 +3015,7 @@ static int do_ssh1_login(Ssh ssh, unsigned char *in, int inlen,
            if (s->dlgret == 0) {
                ssh->close_expected = TRUE;
                ssh_closing((Plug)ssh, NULL, 0, 0);
+               crStop(0);
            }
         }
     }
@@ -3333,6 +3337,7 @@ static int do_ssh1_login(Ssh ssh, unsigned char *in, int inlen,
                    bombout(("TIS challenge packet was badly formed"));
                    crStop(0);
                }
+               c_write_str(ssh, "Using TIS authentication.\r\n");
                logevent("Received TIS challenge");
                if (challengelen > sizeof(s->prompt) - 1)
                    challengelen = sizeof(s->prompt) - 1;/* prevent overrun */
@@ -3366,6 +3371,7 @@ static int do_ssh1_login(Ssh ssh, unsigned char *in, int inlen,
                    bombout(("CryptoCard challenge packet was badly formed"));
                    crStop(0);
                }
+               c_write_str(ssh, "Using CryptoCard authentication.\r\n");
                logevent("Received CryptoCard challenge");
                if (challengelen > sizeof(s->prompt) - 1)
                    challengelen = sizeof(s->prompt) - 1;/* prevent overrun */
@@ -3678,10 +3684,8 @@ void sshfwd_close(struct ssh_channel *c)
 {
     Ssh ssh = c->ssh;
 
-    if (ssh->state != SSH_STATE_SESSION) {
-       assert(ssh->state == SSH_STATE_CLOSED);
+    if (ssh->state == SSH_STATE_CLOSED)
        return;
-    }
 
     if (c && !c->closes) {
        /*
@@ -3718,10 +3722,8 @@ int sshfwd_write(struct ssh_channel *c, char *buf, int len)
 {
     Ssh ssh = c->ssh;
 
-    if (ssh->state != SSH_STATE_SESSION) {
-       assert(ssh->state == SSH_STATE_CLOSED);
+    if (ssh->state == SSH_STATE_CLOSED)
        return 0;
-    }
 
     if (ssh->version == 1) {
        send_packet(ssh, SSH1_MSG_CHANNEL_DATA,
@@ -3747,10 +3749,8 @@ void sshfwd_unthrottle(struct ssh_channel *c, int bufsize)
 {
     Ssh ssh = c->ssh;
 
-    if (ssh->state != SSH_STATE_SESSION) {
-       assert(ssh->state == SSH_STATE_CLOSED);
+    if (ssh->state == SSH_STATE_CLOSED)
        return;
-    }
 
     if (ssh->version == 1) {
        if (c->v.v1.throttling && bufsize < SSH1_BUFFER_LIMIT) {
@@ -3908,7 +3908,7 @@ static void ssh_setup_portfwd(Ssh ssh, const Config *cfg)
                    strcpy(saddr, sports);
                n = 0;
            }
-           if (n < 255) sports[n++] = *portfwd_strptr++;
+           if (n < lenof(sports)-1) sports[n++] = *portfwd_strptr++;
        }
        sports[n] = 0;
        if (type != 'D') {
@@ -3916,14 +3916,14 @@ static void ssh_setup_portfwd(Ssh ssh, const Config *cfg)
                portfwd_strptr++;
            n = 0;
            while (*portfwd_strptr && *portfwd_strptr != ':') {
-               if (n < 255) host[n++] = *portfwd_strptr++;
+               if (n < lenof(host)-1) host[n++] = *portfwd_strptr++;
            }
            host[n] = 0;
            if (*portfwd_strptr == ':')
                portfwd_strptr++;
            n = 0;
            while (*portfwd_strptr) {
-               if (n < 255) dports[n++] = *portfwd_strptr++;
+               if (n < lenof(dports)-1) dports[n++] = *portfwd_strptr++;
            }
            dports[n] = 0;
            portfwd_strptr++;
@@ -5219,6 +5219,7 @@ static int do_ssh2_transport(Ssh ssh, void *vin, int inlen,
            if (s->dlgret == 0) {
                ssh->close_expected = TRUE;
                ssh_closing((Plug)ssh, NULL, 0, 0);
+               crStop(0);
            }
        }
 
@@ -5243,6 +5244,7 @@ static int do_ssh2_transport(Ssh ssh, void *vin, int inlen,
            if (s->dlgret == 0) {
                ssh->close_expected = TRUE;
                ssh_closing((Plug)ssh, NULL, 0, 0);
+               crStop(0);
            }
        }
 
@@ -5267,6 +5269,7 @@ static int do_ssh2_transport(Ssh ssh, void *vin, int inlen,
            if (s->dlgret == 0) {
                ssh->close_expected = TRUE;
                ssh_closing((Plug)ssh, NULL, 0, 0);
+               crStop(0);
            }
        }
 
@@ -6801,6 +6804,7 @@ static void do_ssh2_authconn(Ssh ssh, unsigned char *in, int inlen,
                    continue;
                }
 
+               c_write_str(ssh, "Using keyboard-interactive authentication.\r\n");
                s->kbd_inter_running = TRUE;
                s->curr_prompt = 0;
            }