1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-01-10 09:58:01 +00:00

In ssh_channel_init(), insert the new channel into the channel tree234.

All but one caller was doing this unconditionally.  The one conditional
call was when initialising the main channel, and in consequence PuTTY
leaked a channel structure when the server refused to open the main
channel.  Now it doesn't.
This commit is contained in:
Ben Harris 2016-05-21 22:58:57 +01:00
parent acfab518d2
commit bc48975ce5

8
ssh.c
View File

@ -5521,7 +5521,6 @@ static void ssh1_smsg_x11_open(Ssh ssh, struct Packet *pktin)
c->remoteid = remoteid; c->remoteid = remoteid;
c->halfopen = FALSE; c->halfopen = FALSE;
c->type = CHAN_X11; /* identify channel type */ c->type = CHAN_X11; /* identify channel type */
add234(ssh->channels, c);
send_packet(ssh, SSH1_MSG_CHANNEL_OPEN_CONFIRMATION, send_packet(ssh, SSH1_MSG_CHANNEL_OPEN_CONFIRMATION,
PKT_INT, c->remoteid, PKT_INT, PKT_INT, c->remoteid, PKT_INT,
c->localid, PKT_END); c->localid, PKT_END);
@ -5550,7 +5549,6 @@ static void ssh1_smsg_agent_open(Ssh ssh, struct Packet *pktin)
c->u.a.lensofar = 0; c->u.a.lensofar = 0;
c->u.a.message = NULL; c->u.a.message = NULL;
c->u.a.outstanding_requests = 0; c->u.a.outstanding_requests = 0;
add234(ssh->channels, c);
send_packet(ssh, SSH1_MSG_CHANNEL_OPEN_CONFIRMATION, send_packet(ssh, SSH1_MSG_CHANNEL_OPEN_CONFIRMATION,
PKT_INT, c->remoteid, PKT_INT, c->localid, PKT_INT, c->remoteid, PKT_INT, c->localid,
PKT_END); PKT_END);
@ -5599,7 +5597,6 @@ static void ssh1_msg_port_open(Ssh ssh, struct Packet *pktin)
c->remoteid = remoteid; c->remoteid = remoteid;
c->halfopen = FALSE; c->halfopen = FALSE;
c->type = CHAN_SOCKDATA; /* identify channel type */ c->type = CHAN_SOCKDATA; /* identify channel type */
add234(ssh->channels, c);
send_packet(ssh, SSH1_MSG_CHANNEL_OPEN_CONFIRMATION, send_packet(ssh, SSH1_MSG_CHANNEL_OPEN_CONFIRMATION,
PKT_INT, c->remoteid, PKT_INT, PKT_INT, c->remoteid, PKT_INT,
c->localid, PKT_END); c->localid, PKT_END);
@ -7801,6 +7798,7 @@ static void ssh_channel_init(struct ssh_channel *c)
c->v.v2.throttle_state = UNTHROTTLED; c->v.v2.throttle_state = UNTHROTTLED;
bufchain_init(&c->v.v2.outbuffer); bufchain_init(&c->v.v2.outbuffer);
} }
add234(ssh->channels, c);
} }
/* /*
@ -8863,7 +8861,6 @@ static void ssh2_msg_channel_open(Ssh ssh, struct Packet *pktin)
c->v.v2.locwindow = c->v.v2.locmaxwin = c->v.v2.remlocwin = c->v.v2.locwindow = c->v.v2.locmaxwin = c->v.v2.remlocwin =
our_winsize_override; our_winsize_override;
} }
add234(ssh->channels, c);
pktout = ssh2_pkt_init(SSH2_MSG_CHANNEL_OPEN_CONFIRMATION); pktout = ssh2_pkt_init(SSH2_MSG_CHANNEL_OPEN_CONFIRMATION);
ssh2_pkt_adduint32(pktout, c->remoteid); ssh2_pkt_adduint32(pktout, c->remoteid);
ssh2_pkt_adduint32(pktout, c->localid); ssh2_pkt_adduint32(pktout, c->localid);
@ -10677,7 +10674,6 @@ static void do_ssh2_authconn(Ssh ssh, const unsigned char *in, int inlen,
ssh->mainchan->type = CHAN_MAINSESSION; ssh->mainchan->type = CHAN_MAINSESSION;
ssh->mainchan->v.v2.remwindow = ssh_pkt_getuint32(pktin); ssh->mainchan->v.v2.remwindow = ssh_pkt_getuint32(pktin);
ssh->mainchan->v.v2.remmaxpkt = ssh_pkt_getuint32(pktin); ssh->mainchan->v.v2.remmaxpkt = ssh_pkt_getuint32(pktin);
add234(ssh->channels, ssh->mainchan);
update_specials_menu(ssh->frontend); update_specials_menu(ssh->frontend);
logevent("Opened main channel"); logevent("Opened main channel");
} }
@ -11720,7 +11716,6 @@ void *new_sock_channel(void *handle, struct PortForwarding *pf)
c->halfopen = TRUE; c->halfopen = TRUE;
c->type = CHAN_SOCKDATA_DORMANT;/* identify channel type */ c->type = CHAN_SOCKDATA_DORMANT;/* identify channel type */
c->u.pfd.pf = pf; c->u.pfd.pf = pf;
add234(ssh->channels, c);
return c; return c;
} }
@ -11733,7 +11728,6 @@ unsigned ssh_alloc_sharing_channel(Ssh ssh, void *sharing_ctx)
ssh_channel_init(c); ssh_channel_init(c);
c->type = CHAN_SHARING; c->type = CHAN_SHARING;
c->u.sharing.ctx = sharing_ctx; c->u.sharing.ctx = sharing_ctx;
add234(ssh->channels, c);
return c->localid; return c->localid;
} }