While I'm crusading against arbitrary limits, here's a redesign of
[u/mdw/putty] / ssh.c
diff --git a/ssh.c b/ssh.c
index eee792b..aabbcc4 100644 (file)
--- a/ssh.c
+++ b/ssh.c
@@ -517,9 +517,6 @@ static void ssh_channel_destroy(struct ssh_channel *c);
 #define OUR_V2_MAXPKT 0x4000UL
 #define OUR_V2_PACKETLIMIT 0x9000UL
 
-/* Maximum length of passwords/passphrases (arbitrary) */
-#define SSH_MAX_PASSWORD_LEN 100
-
 const static struct ssh_signkey *hostkey_algs[] = { &ssh_rsa, &ssh_dss };
 
 const static struct ssh_mac *macs[] = {
@@ -3526,8 +3523,7 @@ static int do_ssh1_login(Ssh ssh, unsigned char *in, int inlen,
            s->cur_prompt = new_prompts(ssh->frontend);
            s->cur_prompt->to_server = TRUE;
            s->cur_prompt->name = dupstr("SSH login name");
-           /* 512 is an arbitrary upper limit on username size */
-           add_prompt(s->cur_prompt, dupstr("login as: "), TRUE, 512);
+           add_prompt(s->cur_prompt, dupstr("login as: "), TRUE);
            ret = get_userpass_input(s->cur_prompt, NULL, 0);
            while (ret < 0) {
                ssh->send_ok = 1;
@@ -3573,7 +3569,7 @@ static int do_ssh1_login(Ssh ssh, unsigned char *in, int inlen,
      * Load the public half of any configured keyfile for later use.
      */
     s->keyfile = conf_get_filename(ssh->conf, CONF_keyfile);
-    if (!filename_is_null(*s->keyfile)) {
+    if (!filename_is_null(s->keyfile)) {
        int keytype;
        logeventf(ssh, "Reading private key file \"%.150s\"",
                  filename_to_str(s->keyfile));
@@ -3820,8 +3816,7 @@ static int do_ssh1_login(Ssh ssh, unsigned char *in, int inlen,
                    s->cur_prompt->name = dupstr("SSH key passphrase");
                    add_prompt(s->cur_prompt,
                               dupprintf("Passphrase for key \"%.100s\": ",
-                                        s->publickey_comment),
-                              FALSE, SSH_MAX_PASSWORD_LEN);
+                                        s->publickey_comment), FALSE);
                    ret = get_userpass_input(s->cur_prompt, NULL, 0);
                    while (ret < 0) {
                        ssh->send_ok = 1;
@@ -3976,7 +3971,7 @@ static int do_ssh1_login(Ssh ssh, unsigned char *in, int inlen,
                              (*instr_suf) ? "\n" : "",
                              instr_suf);
                s->cur_prompt->instr_reqd = TRUE;
-               add_prompt(s->cur_prompt, prompt, FALSE, SSH_MAX_PASSWORD_LEN);
+               add_prompt(s->cur_prompt, prompt, FALSE);
                sfree(instr_suf);
            }
        }
@@ -4019,7 +4014,7 @@ static int do_ssh1_login(Ssh ssh, unsigned char *in, int inlen,
                              (*instr_suf) ? "\n" : "",
                              instr_suf);
                s->cur_prompt->instr_reqd = TRUE;
-               add_prompt(s->cur_prompt, prompt, FALSE, SSH_MAX_PASSWORD_LEN);
+               add_prompt(s->cur_prompt, prompt, FALSE);
                sfree(instr_suf);
            }
        }
@@ -4032,7 +4027,7 @@ static int do_ssh1_login(Ssh ssh, unsigned char *in, int inlen,
            s->cur_prompt->name = dupstr("SSH password");
            add_prompt(s->cur_prompt, dupprintf("%s@%s's password: ",
                                                ssh->username, ssh->savedhost),
-                      FALSE, SSH_MAX_PASSWORD_LEN);
+                      FALSE);
        }
 
        /*
@@ -6983,16 +6978,28 @@ static void ssh2_msg_channel_close(Ssh ssh, struct Packet *pktin)
      * the remote side is doing away with the entire channel. (If it
      * had wanted to send us EOF and continue receiving data from us,
      * it would have just sent CHANNEL_EOF.)
-     *
-     * For the moment, this policy applies to the main session channel
-     * only, because we have a convenient mechanism (ssh->send_ok) for
-     * ceasing to read from our local data source. Ideally I think
-     * we'd do this for auxiliary channels too, which would need an
-     * extra API call in the forwarding modules.
      */
-    if (c->type == CHAN_MAINSESSION && !(c->closes & CLOSES_SENT_EOF)) {
+    if (!(c->closes & CLOSES_SENT_EOF)) {
+        /*
+         * Make sure we don't read any more from whatever our local
+         * data source is for this channel.
+         */
+        switch (c->type) {
+          case CHAN_MAINSESSION:
+            ssh->send_ok = 0;     /* stop trying to read from stdin */
+            break;
+          case CHAN_X11:
+           x11_override_throttle(c->u.x11.s, 1);
+           break;
+         case CHAN_SOCKDATA:
+           pfd_override_throttle(c->u.pfd.s, 1);
+           break;
+        }
+
+        /*
+         * Send outgoing EOF.
+         */
         sshfwd_write_eof(ssh->mainchan);
-        ssh->send_ok = 0;          /* now stop trying to read from stdin */
     }
 
     /*
@@ -7517,7 +7524,7 @@ static void do_ssh2_authconn(Ssh ssh, unsigned char *in, int inlen,
         * for later use.
         */
        s->keyfile = conf_get_filename(ssh->conf, CONF_keyfile);
-       if (!filename_is_null(*s->keyfile)) {
+       if (!filename_is_null(s->keyfile)) {
            int keytype;
            logeventf(ssh, "Reading private key file \"%.150s\"",
                      filename_to_str(s->keyfile));
@@ -7663,8 +7670,7 @@ static void do_ssh2_authconn(Ssh ssh, unsigned char *in, int inlen,
            s->cur_prompt = new_prompts(ssh->frontend);
            s->cur_prompt->to_server = TRUE;
            s->cur_prompt->name = dupstr("SSH login name");
-           /* 512 is an arbitrary limit :-( */
-           add_prompt(s->cur_prompt, dupstr("login as: "), TRUE, 512); 
+           add_prompt(s->cur_prompt, dupstr("login as: "), TRUE); 
            ret = get_userpass_input(s->cur_prompt, NULL, 0);
            while (ret < 0) {
                ssh->send_ok = 1;
@@ -8070,7 +8076,7 @@ static void do_ssh2_authconn(Ssh ssh, unsigned char *in, int inlen,
                        add_prompt(s->cur_prompt,
                                   dupprintf("Passphrase for key \"%.100s\": ",
                                             s->publickey_comment),
-                                  FALSE, SSH_MAX_PASSWORD_LEN);
+                                  FALSE);
                        ret = get_userpass_input(s->cur_prompt, NULL, 0);
                        while (ret < 0) {
                            ssh->send_ok = 1;
@@ -8450,7 +8456,7 @@ static void do_ssh2_authconn(Ssh ssh, unsigned char *in, int inlen,
                        }
                        add_prompt(s->cur_prompt,
                                   dupprintf("%.*s", prompt_len, prompt),
-                                  echo, SSH_MAX_PASSWORD_LEN);
+                                   echo);
                    }
 
                    if (name_len) {
@@ -8547,7 +8553,7 @@ static void do_ssh2_authconn(Ssh ssh, unsigned char *in, int inlen,
                add_prompt(s->cur_prompt, dupprintf("%s@%s's password: ",
                                                    ssh->username,
                                                    ssh->savedhost),
-                          FALSE, SSH_MAX_PASSWORD_LEN);
+                          FALSE);
 
                ret = get_userpass_input(s->cur_prompt, NULL, 0);
                while (ret < 0) {
@@ -8649,11 +8655,11 @@ static void do_ssh2_authconn(Ssh ssh, unsigned char *in, int inlen,
                     */
                    add_prompt(s->cur_prompt,
                               dupstr("Current password (blank for previously entered password): "),
-                              FALSE, SSH_MAX_PASSWORD_LEN);
+                              FALSE);
                    add_prompt(s->cur_prompt, dupstr("Enter new password: "),
-                              FALSE, SSH_MAX_PASSWORD_LEN);
+                              FALSE);
                    add_prompt(s->cur_prompt, dupstr("Confirm new password: "),
-                              FALSE, SSH_MAX_PASSWORD_LEN);
+                              FALSE);
 
                    /*
                     * Loop until the user manages to enter the same