Yet _another_ `received data for nonexistent channel' bug. This time
[u/mdw/putty] / ssh.c
diff --git a/ssh.c b/ssh.c
index eac3112..c52301e 100644 (file)
--- a/ssh.c
+++ b/ssh.c
@@ -3019,6 +3019,7 @@ static void ssh1_protocol(Ssh ssh, unsigned char *in, int inlen, int ispkt)
        logevent("Requesting X11 forwarding");
        ssh->x11auth = x11_invent_auth(proto, sizeof(proto),
                                       data, sizeof(data));
+        x11_get_real_auth(ssh->x11auth, cfg.x11_display);
        if (ssh->v1_local_protoflags & SSH1_PROTOFLAG_SCREEN_NUMBER) {
            send_packet(ssh, SSH1_CMSG_X11_REQUEST_FORWARDING,
                        PKT_STR, proto, PKT_STR, data,
@@ -5068,6 +5069,7 @@ static void do_ssh2_authconn(Ssh ssh, unsigned char *in, int inlen, int ispkt)
        logevent("Requesting X11 forwarding");
        ssh->x11auth = x11_invent_auth(proto, sizeof(proto),
                                       data, sizeof(data));
+        x11_get_real_auth(ssh->x11auth, cfg.x11_display);
        ssh2_pkt_init(ssh, SSH2_MSG_CHANNEL_REQUEST);
        ssh2_pkt_adduint32(ssh, ssh->mainchan->remoteid);
        ssh2_pkt_addstring(ssh, "x11-req");
@@ -5587,8 +5589,8 @@ static void do_ssh2_authconn(Ssh ssh, unsigned char *in, int inlen, int ispkt)
                unsigned i = ssh2_pkt_getuint32(ssh);
                struct ssh_channel *c;
                c = find234(ssh->channels, &i, ssh_channelfind);
-               if (!c)
-                   continue;          /* nonexistent channel */
+               if (!c || c->closes)
+                   continue;          /* nonexistent or closing channel */
                c->v.v2.remwindow += ssh2_pkt_getuint32(ssh);
                s->try_send = TRUE;
            } else if (ssh->pktin.type == SSH2_MSG_CHANNEL_OPEN_CONFIRMATION) {
@@ -5809,7 +5811,10 @@ static void do_ssh2_authconn(Ssh ssh, unsigned char *in, int inlen, int ispkt)
             * Try to send data on all channels if we can.
             */
            for (i = 0; NULL != (c = index234(ssh->channels, i)); i++) {
-               int bufsize = ssh2_try_send(c);
+               int bufsize;
+               if (c->closes)
+                   continue;          /* don't send on closing channels */
+               bufsize = ssh2_try_send(c);
                if (bufsize == 0) {
                    switch (c->type) {
                      case CHAN_MAINSESSION: