Add another bug workaround, this one for old OpenSSH (<2.3) servers
[u/mdw/putty] / windlg.c
index fd72288..9299a00 100644 (file)
--- a/windlg.c
+++ b/windlg.c
@@ -559,6 +559,8 @@ enum { IDCX_ABOUT =
     IDC_BUGD_RSAPAD2,
     IDC_BUGS_DHGEX2,
     IDC_BUGD_DHGEX2,
+    IDC_BUGS_PKSESSID2,
+    IDC_BUGD_PKSESSID2,
     sshbugspanelend,
 
     selectionpanelstart,
@@ -660,14 +662,14 @@ static const char *const colours[] = {
 
 static void fmtfont(char *buf)
 {
-    sprintf(buf, "Font: %s, ", cfg.font);
-    if (cfg.fontisbold)
+    sprintf(buf, "Font: %s, ", cfg.font.name);
+    if (cfg.font.isbold)
        strcat(buf, "bold, ");
-    if (cfg.fontheight == 0)
+    if (cfg.font.height == 0)
        strcat(buf, "default height");
     else
        sprintf(buf + strlen(buf), "%d-point",
-               (cfg.fontheight < 0 ? -cfg.fontheight : cfg.fontheight));
+               (cfg.font.height < 0 ? -cfg.font.height : cfg.font.height));
 }
 
 char *help_context_cmd(int id)
@@ -1066,6 +1068,9 @@ char *help_context_cmd(int id)
       case IDC_BUGS_DHGEX2:
       case IDC_BUGD_DHGEX2:
        return "JI(`',`ssh.bugs.dhgex2')";
+      case IDC_BUGS_PKSESSID2:
+      case IDC_BUGD_PKSESSID2:
+       return "JI(`',`ssh.bugs.pksessid2')";
 
       default:
         return NULL;
@@ -1161,7 +1166,7 @@ static void init_dlg_ctrls(HWND hwnd, int keepsess)
                     B_IND_DISABLED ? IDC_B_IND_DISABLED : cfg.beep_ind ==
                     B_IND_FLASH ? IDC_B_IND_FLASH : cfg.beep_ind ==
                     B_IND_STEADY ? IDC_B_IND_STEADY : IDC_B_IND_DISABLED);
-    SetDlgItemText(hwnd, IDC_BELL_WAVEEDIT, cfg.bell_wavefile);
+    SetDlgItemText(hwnd, IDC_BELL_WAVEEDIT, cfg.bell_wavefile.path);
     CheckDlgButton(hwnd, IDC_BELLOVL, cfg.bellovl);
     SetDlgItemInt(hwnd, IDC_BELLOVLN, cfg.bellovl_n, FALSE);
     MySetDlgItemFlt(hwnd, IDC_BELLOVLT, cfg.bellovl_t / 1000.0);
@@ -1197,7 +1202,7 @@ static void init_dlg_ctrls(HWND hwnd, int keepsess)
     SetDlgItemText(hwnd, IDC_R_TSEDIT, cfg.termspeed);
     SetDlgItemText(hwnd, IDC_RLLUSEREDIT, cfg.localusername);
     SetDlgItemText(hwnd, IDC_LOGEDIT, cfg.username);
-    SetDlgItemText(hwnd, IDC_LGFEDIT, cfg.logfilename);
+    SetDlgItemText(hwnd, IDC_LGFEDIT, cfg.logfilename.path);
     CheckRadioButton(hwnd, IDC_LSTATOFF, IDC_LSTATPACKET,
                     cfg.logtype == LGTYP_NONE ? IDC_LSTATOFF :
                     cfg.logtype == LGTYP_ASCII ? IDC_LSTATASCII :
@@ -1240,7 +1245,7 @@ static void init_dlg_ctrls(HWND hwnd, int keepsess)
                     cfg.sshprot == 3 ? IDC_SSHPROT2ONLY : IDC_SSHPROT1ONLY);
     CheckDlgButton(hwnd, IDC_AUTHTIS, cfg.try_tis_auth);
     CheckDlgButton(hwnd, IDC_AUTHKI, cfg.try_ki_auth);
-    SetDlgItemText(hwnd, IDC_PKEDIT, cfg.keyfile);
+    SetDlgItemText(hwnd, IDC_PKEDIT, cfg.keyfile.path);
     SetDlgItemText(hwnd, IDC_CMDEDIT, cfg.remote_cmd);
 
     {
@@ -1426,6 +1431,13 @@ static void init_dlg_ctrls(HWND hwnd, int keepsess)
     SendDlgItemMessage(hwnd, IDC_BUGD_DHGEX2, CB_SETCURSEL,
                       cfg.sshbug_dhgex2 == FORCE_ON ? 2 :
                       cfg.sshbug_dhgex2 == FORCE_OFF ? 1 : 0, 0);
+    SendDlgItemMessage(hwnd, IDC_BUGD_PKSESSID2, CB_RESETCONTENT, 0, 0);
+    SendDlgItemMessage(hwnd, IDC_BUGD_PKSESSID2, CB_ADDSTRING, 0, (LPARAM)"Auto");
+    SendDlgItemMessage(hwnd, IDC_BUGD_PKSESSID2, CB_ADDSTRING, 0, (LPARAM)"Off");
+    SendDlgItemMessage(hwnd, IDC_BUGD_PKSESSID2, CB_ADDSTRING, 0, (LPARAM)"On");
+    SendDlgItemMessage(hwnd, IDC_BUGD_PKSESSID2, CB_SETCURSEL,
+                      cfg.sshbug_pksessid2 == FORCE_ON ? 2 :
+                      cfg.sshbug_pksessid2 == FORCE_OFF ? 1 : 0, 0);
 }
 
 struct treeview_faff {
@@ -2039,6 +2051,8 @@ static void create_controls(HWND hwnd, int dlgtype, int panel)
                      IDC_BUGS_RSAPAD2, IDC_BUGD_RSAPAD2, 20);
            staticddl(&cp, "Chokes on &Diffie-Hellman group exchange",
                      IDC_BUGS_DHGEX2, IDC_BUGD_DHGEX2, 20);
+           staticddl(&cp, "Misuses the sessio&n ID in PK auth",
+                     IDC_BUGS_PKSESSID2, IDC_BUGD_PKSESSID2, 20);
            endbox(&cp);
        }
     }
@@ -2116,7 +2130,7 @@ static int GenericMainDlgProc(HWND hwnd, UINT msg,
     struct treeview_faff tvfaff;
     HTREEITEM hsession;
     OPENFILENAME of;
-    char filename[sizeof(cfg.keyfile)];
+    char filename[sizeof(cfg.keyfile.path)];
     CHOOSEFONT cf;
     LOGFONT lf;
     char fontstatic[256];
@@ -2777,20 +2791,20 @@ static int GenericMainDlgProc(HWND hwnd, UINT msg,
              case IDC_CHOOSEFONT:
                {
                    HDC hdc = GetDC(0);
-                   lf.lfHeight = -MulDiv(cfg.fontheight,
+                   lf.lfHeight = -MulDiv(cfg.font.height,
                                          GetDeviceCaps(hdc, LOGPIXELSY),
                                          72);
                    ReleaseDC(0, hdc);
                }
                lf.lfWidth = lf.lfEscapement = lf.lfOrientation = 0;
                lf.lfItalic = lf.lfUnderline = lf.lfStrikeOut = 0;
-               lf.lfWeight = (cfg.fontisbold ? FW_BOLD : 0);
-               lf.lfCharSet = cfg.fontcharset;
+               lf.lfWeight = (cfg.font.isbold ? FW_BOLD : 0);
+               lf.lfCharSet = cfg.font.charset;
                lf.lfOutPrecision = OUT_DEFAULT_PRECIS;
                lf.lfClipPrecision = CLIP_DEFAULT_PRECIS;
                lf.lfQuality = DEFAULT_QUALITY;
                lf.lfPitchAndFamily = FIXED_PITCH | FF_DONTCARE;
-               strncpy(lf.lfFaceName, cfg.font,
+               strncpy(lf.lfFaceName, cfg.font.name,
                        sizeof(lf.lfFaceName) - 1);
                lf.lfFaceName[sizeof(lf.lfFaceName) - 1] = '\0';
 
@@ -2801,11 +2815,12 @@ static int GenericMainDlgProc(HWND hwnd, UINT msg,
                    CF_INITTOLOGFONTSTRUCT | CF_SCREENFONTS;
 
                if (ChooseFont(&cf)) {
-                   strncpy(cfg.font, lf.lfFaceName, sizeof(cfg.font) - 1);
-                   cfg.font[sizeof(cfg.font) - 1] = '\0';
-                   cfg.fontisbold = (lf.lfWeight == FW_BOLD);
-                   cfg.fontcharset = lf.lfCharSet;
-                   cfg.fontheight = cf.iPointSize / 10;
+                   strncpy(cfg.font.name, lf.lfFaceName,
+                           sizeof(cfg.font.name) - 1);
+                   cfg.font.name[sizeof(cfg.font.name) - 1] = '\0';
+                   cfg.font.isbold = (lf.lfWeight == FW_BOLD);
+                   cfg.font.charset = lf.lfCharSet;
+                   cfg.font.height = cf.iPointSize / 10;
                    fmtfont(fontstatic);
                    SetDlgItemText(hwnd, IDC_FONTSTATIC, fontstatic);
                }
@@ -2852,23 +2867,23 @@ static int GenericMainDlgProc(HWND hwnd, UINT msg,
                of.lpstrCustomFilter = NULL;
                of.nFilterIndex = 1;
                of.lpstrFile = filename;
-               strcpy(filename, cfg.bell_wavefile);
+               strcpy(filename, cfg.bell_wavefile.path);
                of.nMaxFile = sizeof(filename);
                of.lpstrFileTitle = NULL;
                of.lpstrInitialDir = NULL;
                of.lpstrTitle = "Select Bell Sound File";
                of.Flags = 0;
                if (GetOpenFileName(&of)) {
-                   strcpy(cfg.bell_wavefile, filename);
+                   strcpy(cfg.bell_wavefile.path, filename);
                    SetDlgItemText(hwnd, IDC_BELL_WAVEEDIT,
-                                  cfg.bell_wavefile);
+                                  cfg.bell_wavefile.path);
                }
                break;
              case IDC_BELL_WAVEEDIT:
                if (HIWORD(wParam) == EN_CHANGE)
                    GetDlgItemText(hwnd, IDC_BELL_WAVEEDIT,
-                                  cfg.bell_wavefile,
-                                  sizeof(cfg.bell_wavefile) - 1);
+                                  cfg.bell_wavefile.path,
+                                  sizeof(cfg.bell_wavefile.path) - 1);
                break;
              case IDC_BELLOVL:
                if (HIWORD(wParam) == BN_CLICKED ||
@@ -3090,8 +3105,8 @@ static int GenericMainDlgProc(HWND hwnd, UINT msg,
 
              case IDC_LGFEDIT:
                if (HIWORD(wParam) == EN_CHANGE)
-                   GetDlgItemText(hwnd, IDC_LGFEDIT, cfg.logfilename,
-                                  sizeof(cfg.logfilename) - 1);
+                   GetDlgItemText(hwnd, IDC_LGFEDIT, cfg.logfilename.path,
+                                  sizeof(cfg.logfilename.path) - 1);
                break;
              case IDC_LGFBUTTON:
                memset(&of, 0, sizeof(of));
@@ -3105,15 +3120,15 @@ static int GenericMainDlgProc(HWND hwnd, UINT msg,
                of.lpstrCustomFilter = NULL;
                of.nFilterIndex = 1;
                of.lpstrFile = filename;
-               strcpy(filename, cfg.logfilename);
+               strcpy(filename, cfg.logfilename.path);
                of.nMaxFile = sizeof(filename);
                of.lpstrFileTitle = NULL;
                of.lpstrInitialDir = NULL;
                of.lpstrTitle = "Select session log file";
                of.Flags = 0;
                if (GetSaveFileName(&of)) {
-                   strcpy(cfg.logfilename, filename);
-                   SetDlgItemText(hwnd, IDC_LGFEDIT, cfg.logfilename);
+                   strcpy(cfg.logfilename.path, filename);
+                   SetDlgItemText(hwnd, IDC_LGFEDIT, cfg.logfilename.path);
                }
                break;
              case IDC_LSTATOFF:
@@ -3313,8 +3328,8 @@ static int GenericMainDlgProc(HWND hwnd, UINT msg,
                break;
              case IDC_PKEDIT:
                if (HIWORD(wParam) == EN_CHANGE)
-                   GetDlgItemText(hwnd, IDC_PKEDIT, cfg.keyfile,
-                                  sizeof(cfg.keyfile) - 1);
+                   GetDlgItemText(hwnd, IDC_PKEDIT, cfg.keyfile.path,
+                                  sizeof(cfg.keyfile.path) - 1);
                break;
              case IDC_CMDEDIT:
                if (HIWORD(wParam) == EN_CHANGE)
@@ -3334,15 +3349,15 @@ static int GenericMainDlgProc(HWND hwnd, UINT msg,
                of.lpstrCustomFilter = NULL;
                of.nFilterIndex = 1;
                of.lpstrFile = filename;
-               strcpy(filename, cfg.keyfile);
+               strcpy(filename, cfg.keyfile.path);
                of.nMaxFile = sizeof(filename);
                of.lpstrFileTitle = NULL;
                of.lpstrInitialDir = NULL;
                of.lpstrTitle = "Select Private Key File";
                of.Flags = 0;
                if (GetOpenFileName(&of)) {
-                   strcpy(cfg.keyfile, filename);
-                   SetDlgItemText(hwnd, IDC_PKEDIT, cfg.keyfile);
+                   strcpy(cfg.keyfile.path, filename);
+                   SetDlgItemText(hwnd, IDC_PKEDIT, cfg.keyfile.path);
                }
                break;
              case IDC_RAWCNP:
@@ -3677,6 +3692,14 @@ static int GenericMainDlgProc(HWND hwnd, UINT msg,
                                         index == 1 ? FORCE_OFF : FORCE_ON);
                }
                break;
+             case IDC_BUGD_PKSESSID2:
+               if (HIWORD(wParam) == CBN_SELCHANGE) {
+                   int index = SendDlgItemMessage(hwnd, IDC_BUGD_PKSESSID2,
+                                                  CB_GETCURSEL, 0, 0);
+                   cfg.sshbug_pksessid2 = (index == 0 ? AUTO :
+                                            index == 1 ? FORCE_OFF : FORCE_ON);
+               }
+               break;
            }
        return 0;
       case WM_HELP:
@@ -3941,7 +3964,7 @@ void askcipher(void *frontend, char *ciphername, int cs)
  * Ask whether to wipe a session log file before writing to it.
  * Returns 2 for wipe, 1 for append, 0 for cancel (don't log).
  */
-int askappend(void *frontend, char *filename)
+int askappend(void *frontend, Filename filename)
 {
     static const char mbtitle[] = "PuTTY Log to File";
     static const char msgtemplate[] =
@@ -3954,7 +3977,7 @@ int askappend(void *frontend, char *filename)
     char message[sizeof(msgtemplate) + FILENAME_MAX];
     int mbret;
 
-    sprintf(message, msgtemplate, FILENAME_MAX, filename);
+    sprintf(message, msgtemplate, FILENAME_MAX, filename.path);
 
     mbret = MessageBox(NULL, message, mbtitle,
                       MB_ICONQUESTION | MB_YESNOCANCEL);