X-Git-Url: https://git.distorted.org.uk/~mdw/sgt/putty/blobdiff_plain/b165006759a81e8ecc4e86e0540fd69343ea46e9..3980e64ffbb86a37d6810b004a04a21f338a408b:/ssh.c diff --git a/ssh.c b/ssh.c index ce3a5278..16ef0567 100644 --- a/ssh.c +++ b/ssh.c @@ -4869,14 +4869,11 @@ static void ssh1_msg_port_open(Ssh ssh, struct Packet *pktin) { /* Remote side is trying to open a channel to talk to a * forwarded port. Give them back a local channel number. */ - struct ssh_channel *c; struct ssh_rportfwd pf, *pfp; int remoteid; int hostsize, port; char *host; const char *e; - c = snew(struct ssh_channel); - c->ssh = ssh; remoteid = ssh_pkt_getuint32(pktin); ssh_pkt_getstring(pktin, &host, &hostsize); @@ -4895,6 +4892,9 @@ static void ssh1_msg_port_open(Ssh ssh, struct Packet *pktin) send_packet(ssh, SSH1_MSG_CHANNEL_OPEN_FAILURE, PKT_INT, remoteid, PKT_END); } else { + struct ssh_channel *c = snew(struct ssh_channel); + c->ssh = ssh; + logeventf(ssh, "Received remote port open request for %s:%d", pf.dhost, port); e = pfd_newconnect(&c->u.pfd.s, pf.dhost, port, @@ -5909,6 +5909,16 @@ static void do_ssh2_transport(Ssh ssh, void *vin, int inlen, ssh_pkt_getstring(pktin, &str, &len); /* server->client language */ s->ignorepkt = ssh2_pkt_getbool(pktin) && !s->guessok; + ssh->exhash = ssh->kex->hash->init(); + hash_string(ssh->kex->hash, ssh->exhash, ssh->v_c, strlen(ssh->v_c)); + hash_string(ssh->kex->hash, ssh->exhash, ssh->v_s, strlen(ssh->v_s)); + hash_string(ssh->kex->hash, ssh->exhash, + s->our_kexinit, s->our_kexinitlen); + sfree(s->our_kexinit); + if (pktin->length > 5) + hash_string(ssh->kex->hash, ssh->exhash, + pktin->data + 5, pktin->length - 5); + if (s->warn_kex) { ssh_set_frozen(ssh, 1); s->dlgret = askalg(ssh->frontend, "key-exchange algorithm", @@ -5983,16 +5993,6 @@ static void do_ssh2_transport(Ssh ssh, void *vin, int inlen, } } - ssh->exhash = ssh->kex->hash->init(); - hash_string(ssh->kex->hash, ssh->exhash, ssh->v_c, strlen(ssh->v_c)); - hash_string(ssh->kex->hash, ssh->exhash, ssh->v_s, strlen(ssh->v_s)); - hash_string(ssh->kex->hash, ssh->exhash, - s->our_kexinit, s->our_kexinitlen); - sfree(s->our_kexinit); - if (pktin->length > 5) - hash_string(ssh->kex->hash, ssh->exhash, - pktin->data + 5, pktin->length - 5); - if (s->ignorepkt) /* first_kex_packet_follows */ crWaitUntilV(pktin); /* Ignore packet */ } @@ -7543,7 +7543,9 @@ static void ssh2_setup_x11(struct ssh_channel *c, struct Packet *pktin, ssh2_pkt_adduint32(pktout, ssh->x11disp->screennum); ssh2_pkt_send(ssh, pktout); - crWaitUntilV(pktin); + /* Wait to be called back with either a response packet, or NULL + * meaning clean up and free our data */ + crReturnV; if (pktin) { if (pktin->type == SSH2_MSG_CHANNEL_SUCCESS) { @@ -7573,7 +7575,9 @@ static void ssh2_setup_agent(struct ssh_channel *c, struct Packet *pktin, ssh2_setup_agent, s); ssh2_pkt_send(ssh, pktout); - crWaitUntilV(pktin); + /* Wait to be called back with either a response packet, or NULL + * meaning clean up and free our data */ + crReturnV; if (pktin) { if (pktin->type == SSH2_MSG_CHANNEL_SUCCESS) { @@ -7620,7 +7624,9 @@ static void ssh2_setup_pty(struct ssh_channel *c, struct Packet *pktin, ssh2_pkt_send(ssh, pktout); ssh->state = SSH_STATE_INTERMED; - crWaitUntilV(pktin); + /* Wait to be called back with either a response packet, or NULL + * meaning clean up and free our data */ + crReturnV; if (pktin) { if (pktin->type == SSH2_MSG_CHANNEL_SUCCESS) { @@ -7678,7 +7684,9 @@ static void ssh2_setup_env(struct ssh_channel *c, struct Packet *pktin, s->env_left = s->num_env; while (s->env_left > 0) { - crWaitUntilV(pktin); + /* Wait to be called back with either a response packet, + * or NULL meaning clean up and free our data */ + crReturnV; if (!pktin) goto out; if (pktin->type == SSH2_MSG_CHANNEL_SUCCESS) s->env_ok++;