Simplify handling of responses to channel requests.
authorben <ben@cda61777-01e9-0310-a592-d414129be87e>
Sat, 25 Aug 2012 15:04:29 +0000 (15:04 +0000)
committerben <ben@cda61777-01e9-0310-a592-d414129be87e>
Sat, 25 Aug 2012 15:04:29 +0000 (15:04 +0000)
The various setup routines can only receive CHANNEL_SUCCESS or
CHANNEL_FAILURE, so there's no need for the to worry about receiving
anything else.  Strange packets will end up in do_ssh2_authconn
instead.

git-svn-id: svn://svn.tartarus.org/sgt/putty@9619 cda61777-01e9-0310-a592-d414129be87e

ssh.c

diff --git a/ssh.c b/ssh.c
index 3ab9725..4de58f9 100644 (file)
--- a/ssh.c
+++ b/ssh.c
@@ -7490,18 +7490,11 @@ static void ssh2_maybe_setup_x11(struct ssh_channel *c, struct Packet *pktin,
 
        crWaitUntilV(pktin);
 
-       if (pktin->type != SSH2_MSG_CHANNEL_SUCCESS) {
-           if (pktin->type != SSH2_MSG_CHANNEL_FAILURE) {
-               bombout(("Unexpected response to X11 forwarding request:"
-                        " packet type %d", pktin->type));
-               sfree(s);
-               crStopV;
-           }
-           logevent("X11 forwarding refused");
-       } else {
+       if (pktin->type == SSH2_MSG_CHANNEL_SUCCESS) {
            logevent("X11 forwarding enabled");
            ssh->X11_fwd_enabled = TRUE;
-       }
+       } else
+           logevent("X11 forwarding refused");
     }
     sfree(s);
     crFinishV;
@@ -7531,17 +7524,11 @@ static void ssh2_maybe_setup_agent(struct ssh_channel *c, struct Packet *pktin,
 
        crWaitUntilV(pktin);
 
-       if (pktin->type != SSH2_MSG_CHANNEL_SUCCESS) {
-           if (pktin->type != SSH2_MSG_CHANNEL_FAILURE) {
-               bombout(("Unexpected response to agent forwarding request:"
-                        " packet type %d", pktin->type));
-               crStopV;
-           }
-           logevent("Agent forwarding refused");
-       } else {
+       if (pktin->type == SSH2_MSG_CHANNEL_SUCCESS) {
            logevent("Agent forwarding enabled");
            ssh->agentfwd_enabled = TRUE;
-       }
+       } else
+           logevent("Agent forwarding refused");
     }
     sfree(s);
     crFinishV;
@@ -7588,18 +7575,13 @@ static void ssh2_maybe_setup_pty(struct ssh_channel *c, struct Packet *pktin,
 
        crWaitUntilV(pktin);
 
-       if (pktin->type != SSH2_MSG_CHANNEL_SUCCESS) {
-           if (pktin->type != SSH2_MSG_CHANNEL_FAILURE) {
-               bombout(("Unexpected response to pty request:"
-                        " packet type %d", pktin->type));
-               crStopV;
-           }
-           c_write_str(ssh, "Server refused to allocate pty\r\n");
-           ssh->editing = ssh->echoing = 1;
-       } else {
+       if (pktin->type == SSH2_MSG_CHANNEL_SUCCESS) {
            logeventf(ssh, "Allocated pty (ospeed %dbps, ispeed %dbps)",
                      ssh->ospeed, ssh->ispeed);
             ssh->got_pty = TRUE;
+       } else {
+           c_write_str(ssh, "Server refused to allocate pty\r\n");
+           ssh->editing = ssh->echoing = 1;
        }
     } else {
        ssh->editing = ssh->echoing = 1;
@@ -7655,17 +7637,8 @@ static void ssh2_setup_env(struct ssh_channel *c, struct Packet *pktin,
 
        while (s->env_left > 0) {
            crWaitUntilV(pktin);
-
-           if (pktin->type != SSH2_MSG_CHANNEL_SUCCESS) {
-               if (pktin->type != SSH2_MSG_CHANNEL_FAILURE) {
-                   bombout(("Unexpected response to environment request:"
-                            " packet type %d", pktin->type));
-                   crStopV;
-               }
-           } else {
+           if (pktin->type == SSH2_MSG_CHANNEL_SUCCESS)
                s->env_ok++;
-           }
-
            s->env_left--;
        }