When we receive CHANNEL_CLOSE on an SSH-2 channel and haven't sent EOF
[u/mdw/putty] / ssh.c
diff --git a/ssh.c b/ssh.c
index aabbcc4..6d5ebd4 100644 (file)
--- a/ssh.c
+++ b/ssh.c
@@ -6551,9 +6551,10 @@ static void ssh2_set_window(struct ssh_channel *c, int newwin)
     /*
      * Never send WINDOW_ADJUST for a channel that the remote side has
      * already sent EOF on; there's no point, since it won't be
-     * sending any more data anyway.
+     * sending any more data anyway. Ditto if _we've_ already sent
+     * CLOSE.
      */
-    if (c->closes & CLOSES_RCVD_EOF)
+    if (c->closes & (CLOSES_RCVD_EOF | CLOSES_SENT_CLOSE))
        return;
 
     /*
@@ -6563,7 +6564,6 @@ static void ssh2_set_window(struct ssh_channel *c, int newwin)
      */
     if ((ssh->remote_bugs & BUG_SSH2_MAXPKT) && newwin > OUR_V2_MAXPKT)
        newwin = OUR_V2_MAXPKT;
-       
 
     /*
      * Only send a WINDOW_ADJUST if there's significantly more window
@@ -6999,7 +6999,7 @@ static void ssh2_msg_channel_close(Ssh ssh, struct Packet *pktin)
         /*
          * Send outgoing EOF.
          */
-        sshfwd_write_eof(ssh->mainchan);
+        sshfwd_write_eof(c);
     }
 
     /*
@@ -8524,6 +8524,13 @@ static void do_ssh2_authconn(Ssh ssh, unsigned char *in, int inlen,
                    }
                    ssh2_pkt_send_with_padding(ssh, s->pktout, 256);
 
+                    /*
+                     * Free the prompts structure from this iteration.
+                     * If there's another, a new one will be allocated
+                     * when we return to the top of this while loop.
+                     */
+                    free_prompts(s->cur_prompt);
+
                    /*
                     * Get the next packet in case it's another
                     * INFO_REQUEST.