Fix the SSH protocol version exchange, which had a weird stack trash
[u/mdw/putty] / settings.c
index 01087ee..a505050 100644 (file)
@@ -72,9 +72,11 @@ void save_settings (char *section, int do_host, Config *cfg) {
     write_setting_i (sesskey, "NoPTY", cfg->nopty);
     write_setting_i (sesskey, "Compression", cfg->compression);
     write_setting_i (sesskey, "AgentFwd", cfg->agentfwd);
-    write_setting_s (sesskey, "RemoteCmd", cfg->remote_cmd);
-    write_setting_s (sesskey, "Cipher", cfg->cipher == CIPHER_BLOWFISH ? "blowfish" :
-                             cfg->cipher == CIPHER_DES ? "des" : "3des");
+    write_setting_s (sesskey, "Cipher",
+                     cfg->cipher == CIPHER_BLOWFISH ? "blowfish" :
+                     cfg->cipher == CIPHER_DES ? "des" :
+                     cfg->cipher == CIPHER_AES ? "aes" :
+                     "3des");
     write_setting_i (sesskey, "AuthTIS", cfg->try_tis_auth);
     write_setting_i (sesskey, "SshProt", cfg->sshprot);
     write_setting_i (sesskey, "BuggyMAC", cfg->buggymac);
@@ -158,6 +160,7 @@ void load_settings (char *section, int do_host, Config *cfg) {
     sesskey = open_settings_r(section);
 
     cfg->ssh_subsys = 0;               /* FIXME: load this properly */
+    cfg->remote_cmd_ptr = cfg->remote_cmd;
 
     gpps (sesskey, "HostName", "", cfg->host, sizeof(cfg->host));
     gppi (sesskey, "PortNumber", default_port, &cfg->port);
@@ -210,7 +213,6 @@ void load_settings (char *section, int do_host, Config *cfg) {
     gppi (sesskey, "NoPTY", 0, &cfg->nopty);
     gppi (sesskey, "Compression", 0, &cfg->compression);
     gppi (sesskey, "AgentFwd", 0, &cfg->agentfwd);
-    gpps (sesskey, "RemoteCmd", "", cfg->remote_cmd, sizeof(cfg->remote_cmd));
     {
        char cipher[10];
        gpps (sesskey, "Cipher", "3des", cipher, 10);
@@ -218,6 +220,8 @@ void load_settings (char *section, int do_host, Config *cfg) {
            cfg->cipher = CIPHER_BLOWFISH;
        else if (!strcmp(cipher, "des"))
            cfg->cipher = CIPHER_DES;
+       else if (!strcmp(cipher, "aes"))
+           cfg->cipher = CIPHER_AES;
        else
            cfg->cipher = CIPHER_3DES;
     }
@@ -259,6 +263,18 @@ void load_settings (char *section, int do_host, Config *cfg) {
     gppi (sesskey, "FontIsBold", 0, &cfg->fontisbold);
     gppi (sesskey, "FontCharSet", ANSI_CHARSET, &cfg->fontcharset);
     gppi (sesskey, "FontHeight", 10, &cfg->fontheight);
+    if (cfg->fontheight < 0) {
+        int oldh, newh;
+        HDC hdc = GetDC(NULL);
+        int logpix = GetDeviceCaps(hdc, LOGPIXELSY);
+        ReleaseDC(NULL, hdc);
+
+        oldh = -cfg->fontheight;
+        newh = MulDiv(oldh, 72, logpix) + 1;
+        if (MulDiv(newh, logpix, 72) > oldh)
+            newh--;
+        cfg->fontheight = newh;
+    }
     gppi (sesskey, "FontVTMode", VT_OEMANSI, (int *)&cfg->vtmode);
     gppi (sesskey, "TryPalette", 0, &cfg->try_palette);
     gppi (sesskey, "BoldAsColour", 1, &cfg->bold_colour);