Platform-independent fixes for NO_IPV6 compilation (prevent
[u/mdw/putty] / config.c
index 474654d..5b44c01 100644 (file)
--- a/config.c
+++ b/config.c
@@ -402,7 +402,7 @@ static void sessionsaver_handler(union control *ctrl, void *dlg,
                /* If at this point we have a valid session, go! */
                if (*cfg2.host) {
                    *cfg = cfg2;       /* structure copy */
-                   cfg->remote_cmd_ptr = cfg->remote_cmd; /* nasty */
+                   cfg->remote_cmd_ptr = NULL;
                    dlg_end(dlg, 1);
                } else
                    dlg_beep(dlg);
@@ -666,7 +666,9 @@ static void environ_handler(union control *ctrl, void *dlg,
 struct portfwd_data {
     union control *addbutton, *rembutton, *listbox;
     union control *sourcebox, *destbox, *direction;
+#ifndef NO_IPV6
     union control *addressfamily;
+#endif
 };
 
 static void portfwd_handler(union control *ctrl, void *dlg,
@@ -691,8 +693,10 @@ static void portfwd_handler(union control *ctrl, void *dlg,
             * Default is Local.
             */
            dlg_radiobutton_set(ctrl, dlg, 0);
-        } else if (ctrl == pfd->addressfamily) {
+#ifndef NO_IPV6
+       } else if (ctrl == pfd->addressfamily) {
            dlg_radiobutton_set(ctrl, dlg, 0);
+#endif
        }
     } else if (event == EVENT_ACTION) {
        if (ctrl == pfd->addbutton) {
@@ -702,11 +706,13 @@ static void portfwd_handler(union control *ctrl, void *dlg,
            int whichbutton;
 
            i = 0;
+#ifndef NO_IPV6
            whichbutton = dlg_radiobutton_get(pfd->addressfamily, dlg);
            if (whichbutton == 1)
                str[i++] = '4';
            else if (whichbutton == 2)
                str[i++] = '6';
+#endif
 
            whichbutton = dlg_radiobutton_get(pfd->direction, dlg);
            if (whichbutton == 0)
@@ -718,7 +724,7 @@ static void portfwd_handler(union control *ctrl, void *dlg,
            str[i++] = type;
 
            dlg_editbox_get(pfd->sourcebox, dlg, str+i, sizeof(str) - i);
-           if (!str[2]) {
+           if (!str[i]) {
                dlg_error_msg(dlg, "You need to specify a source port number");
                return;
            }
@@ -726,7 +732,7 @@ static void portfwd_handler(union control *ctrl, void *dlg,
            if (type != 'D') {
                *p++ = '\t';
                dlg_editbox_get(pfd->destbox, dlg, p,
-                               sizeof(str)-1 - (p - str));
+                               sizeof(str) - (p - str));
                if (!*p || !strchr(p, ':')) {
                    dlg_error_msg(dlg,
                                  "You need to specify a destination address\n"
@@ -741,7 +747,7 @@ static void portfwd_handler(union control *ctrl, void *dlg,
                    p++;
                p++;
            }
-           if ((p - cfg->portfwd) + strlen(str) + 2 <
+           if ((p - cfg->portfwd) + strlen(str) + 2 <=
                sizeof(cfg->portfwd)) {
                strcpy(p, str);
                p[strlen(str) + 1] = '\0';
@@ -1378,23 +1384,18 @@ void setup_config_box(struct controlbox *b, struct sesslist *sesslist,
                          'p', HELPCTX(connection_tcpkeepalive),
                          dlg_stdcheckbox_handler,
                          I(offsetof(Config,tcp_keepalives)));
+#ifndef NO_IPV6
            s = ctrl_getset(b, "Connection", "ipversion",
                          "Internet protocol version");
-           ctrl_radiobuttons(s, NULL, NO_SHORTCUT,
-#ifndef NO_IPV6
-                         3,
-#else
-                         2,
-#endif
+           ctrl_radiobuttons(s, NULL, NO_SHORTCUT, 3,
                          HELPCTX(connection_ipversion),
                          dlg_stdradiobutton_handler,
                          I(offsetof(Config, addressfamily)),
                          "Auto", NO_SHORTCUT, I(ADDRTYPE_UNSPEC),
                          "IPv4", NO_SHORTCUT, I(ADDRTYPE_IPV4),
-#ifndef NO_IPV6
                          "IPv6", NO_SHORTCUT, I(ADDRTYPE_IPV6),
-#endif
                          NULL);
+#endif
        }
 
        /*
@@ -1663,7 +1664,7 @@ void setup_config_box(struct controlbox *b, struct sesslist *sesslist,
 
            s = ctrl_getset(b, "Connection/SSH/Kex", "main",
                            "Key exchange algorithm options");
-           c = ctrl_draglist(s, "Algorithm selection policy", 's',
+           c = ctrl_draglist(s, "Algorithm selection policy:", 's',
                              HELPCTX(ssh_kexlist),
                              kexlist_handler, P(NULL));
            c->listbox.height = 5;
@@ -1801,21 +1802,16 @@ void setup_config_box(struct controlbox *b, struct sesslist *sesslist,
                                           "Remote", 'm', P(NULL),
                                           "Dynamic", 'y', P(NULL),
                                           NULL);
-       pfd->addressfamily =
-           ctrl_radiobuttons(s, NULL, NO_SHORTCUT,
 #ifndef NO_IPV6
-                             3,
-#else
-                             2,
-#endif
+       pfd->addressfamily =
+           ctrl_radiobuttons(s, NULL, NO_SHORTCUT, 3,
                              HELPCTX(ssh_tunnels_portfwd_ipversion),
                              portfwd_handler, P(pfd),
                              "Auto", NO_SHORTCUT, I(ADDRTYPE_UNSPEC),
                              "IPv4", NO_SHORTCUT, I(ADDRTYPE_IPV4),
-#ifndef NO_IPV6
                              "IPv6", NO_SHORTCUT, I(ADDRTYPE_IPV6),
-#endif
                              NULL);
+#endif
        ctrl_tabdelay(s, pfd->addbutton);
        ctrl_columns(s, 1, 100);
 
@@ -1849,6 +1845,9 @@ void setup_config_box(struct controlbox *b, struct sesslist *sesslist,
            ctrl_droplist(s, "Misuses the session ID in PK auth", 'n', 20,
                          HELPCTX(ssh_bugs_pksessid2),
                          sshbug_handler, I(offsetof(Config,sshbug_pksessid2)));
+           ctrl_droplist(s, "Handles key re-exchange badly", 'k', 20,
+                         HELPCTX(ssh_bugs_rekey2),
+                         sshbug_handler, I(offsetof(Config,sshbug_rekey2)));
        }
     }
 }