Put back the code that ensures "Default Settings" is always in the
[u/mdw/putty] / settings.c
index 181708e..69394f2 100644 (file)
@@ -78,6 +78,7 @@ void save_settings (char *section, int do_host, Config *cfg) {
                              cfg->cipher == CIPHER_DES ? "des" : "3des");
     write_setting_i (sesskey, "AuthTIS", cfg->try_tis_auth);
     write_setting_i (sesskey, "SshProt", cfg->sshprot);
+    write_setting_i (sesskey, "BuggyMAC", cfg->buggymac);
     write_setting_s (sesskey, "PublicKeyFile", cfg->keyfile);
     write_setting_s (sesskey, "RemoteCommand", cfg->remote_cmd);
     write_setting_i (sesskey, "RFCEnviron", cfg->rfc_environ);
@@ -198,6 +199,7 @@ void load_settings (char *section, int do_host, Config *cfg) {
            cfg->cipher = CIPHER_3DES;
     }
     gppi (sesskey, "SshProt", 1, &cfg->sshprot);
+    gppi (sesskey, "BuggyMAC", 0, &cfg->buggymac);
     gppi (sesskey, "AuthTIS", 0, &cfg->try_tis_auth);
     gpps (sesskey, "PublicKeyFile", "", cfg->keyfile, sizeof(cfg->keyfile));
     gpps (sesskey, "RemoteCommand", "", cfg->remote_cmd,
@@ -336,19 +338,28 @@ void get_sesslist(int allocate) {
        buffer = srealloc(buffer, buflen+1);
        buffer[buflen] = '\0';
 
+       /*
+        * Now set up the list of sessions. Note that "Default
+        * Settings" must always be claimed to exist, even if it
+        * doesn't really.
+        */
+
        p = buffer;
-       nsessions = 0;
+       nsessions = 1;                 /* "Default Settings" counts as one */
        while (*p) {
-            nsessions++;
+            if (strcmp(p, "Default Settings"))
+               nsessions++;
            while (*p) p++;
            p++;
        }
 
-       sessions = smalloc(nsessions * sizeof(char *));
+       sessions = smalloc((nsessions+1) * sizeof(char *));
+       sessions[0] = "Default Settings";
        p = buffer;
-       i = 0;
+       i = 1;
        while (*p) {
-            sessions[i++] = p;
+            if (strcmp(p, "Default Settings"))
+               sessions[i++] = p;
            while (*p) p++;
            p++;
        }