Various error-handling fixes, mostly in Unix PuTTY but one (failure
[u/mdw/putty] / settings.c
index 47524db..1de8e51 100644 (file)
@@ -20,16 +20,42 @@ static const struct keyval ciphernames[] = {
     { "des",       CIPHER_DES }
 };
 
-static void gpps(void *handle, char *name, char *def, char *val, int len)
+static void gpps(void *handle, const char *name, const char *def,
+                char *val, int len)
 {
     if (!read_setting_s(handle, name, val, len)) {
-       strncpy(val, def, len);
+       char *pdef;
+
+       pdef = platform_default_s(name);
+       if (pdef) {
+           strncpy(val, pdef, len);
+       } else {
+           strncpy(val, def, len);
+       }
+
        val[len - 1] = '\0';
     }
 }
 
+/*
+ * gppfont and gppfile cannot have local defaults, since the very
+ * format of a Filename or Font is platform-dependent. So the
+ * platform-dependent functions MUST return some sort of value.
+ */
+static void gppfont(void *handle, const char *name, FontSpec *result)
+{
+    if (!read_setting_fontspec(handle, name, result))
+       *result = platform_default_fontspec(name);
+}
+static void gppfile(void *handle, const char *name, Filename *result)
+{
+    if (!read_setting_filename(handle, name, result))
+       *result = platform_default_filename(name);
+}
+
 static void gppi(void *handle, char *name, int def, int *i)
 {
+    def = platform_default_i(name, def);
     *i = read_setting_i(handle, name, def);
 }
 
@@ -115,20 +141,28 @@ static void wprefs(void *sesskey, char *name,
     write_setting_s(sesskey, name, buf);
 }
 
-void save_settings(char *section, int do_host, Config * cfg)
+char *save_settings(char *section, int do_host, Config * cfg)
 {
-    int i;
-    char *p;
     void *sesskey;
+    char *errmsg;
 
-    sesskey = open_settings_w(section);
+    sesskey = open_settings_w(section, &errmsg);
     if (!sesskey)
-       return;
+       return errmsg;
+    save_open_settings(sesskey, do_host, cfg);
+    close_settings_w(sesskey);
+    return NULL;
+}
+
+void save_open_settings(void *sesskey, int do_host, Config *cfg)
+{
+    int i;
+    char *p;
 
     write_setting_i(sesskey, "Present", 1);
     if (do_host) {
        write_setting_s(sesskey, "HostName", cfg->host);
-       write_setting_s(sesskey, "LogFileName", cfg->logfilename);
+       write_setting_filename(sesskey, "LogFileName", cfg->logfilename);
        write_setting_i(sesskey, "LogType", cfg->logtype);
        write_setting_i(sesskey, "LogFileClash", cfg->logxfovr);
     }
@@ -140,7 +174,9 @@ void save_settings(char *section, int do_host, Config * cfg)
        }
     write_setting_s(sesskey, "Protocol", p);
     write_setting_i(sesskey, "PortNumber", cfg->port);
-    write_setting_i(sesskey, "CloseOnExit", cfg->close_on_exit);
+    /* The CloseOnExit numbers are arranged in a different order from
+     * the standard FORCE_ON / FORCE_OFF / AUTO. */
+    write_setting_i(sesskey, "CloseOnExit", (cfg->close_on_exit+2)%3);
     write_setting_i(sesskey, "WarnOnClose", !!cfg->warn_on_close);
     write_setting_i(sesskey, "PingInterval", cfg->ping_interval / 60); /* minutes */
     write_setting_i(sesskey, "PingIntervalSecs", cfg->ping_interval % 60);     /* seconds */
@@ -150,6 +186,8 @@ void save_settings(char *section, int do_host, Config * cfg)
 
     /* proxy settings */
     write_setting_s(sesskey, "ProxyExcludeList", cfg->proxy_exclude_list);
+    write_setting_i(sesskey, "ProxyDNS", (cfg->proxy_dns+2)%3);
+    write_setting_i(sesskey, "ProxyLocalhost", cfg->even_proxy_localhost);
     write_setting_i(sesskey, "ProxyType", cfg->proxy_type);
     write_setting_s(sesskey, "ProxyHost", cfg->proxy_host);
     write_setting_i(sesskey, "ProxyPort", cfg->proxy_port);
@@ -189,7 +227,7 @@ void save_settings(char *section, int do_host, Config * cfg)
     write_setting_i(sesskey, "AuthKI", cfg->try_ki_auth);
     write_setting_i(sesskey, "SshProt", cfg->sshprot);
     write_setting_i(sesskey, "SSH2DES", cfg->ssh2_des_cbc);
-    write_setting_s(sesskey, "PublicKeyFile", cfg->keyfile);
+    write_setting_filename(sesskey, "PublicKeyFile", cfg->keyfile);
     write_setting_s(sesskey, "RemoteCommand", cfg->remote_cmd);
     write_setting_i(sesskey, "RFCEnviron", cfg->rfc_environ);
     write_setting_i(sesskey, "PassiveTelnet", cfg->passive_telnet);
@@ -226,7 +264,7 @@ void save_settings(char *section, int do_host, Config * cfg)
     write_setting_i(sesskey, "BlinkCur", cfg->blink_cur);
     write_setting_i(sesskey, "Beep", cfg->beep);
     write_setting_i(sesskey, "BeepInd", cfg->beep_ind);
-    write_setting_s(sesskey, "BellWaveFile", cfg->bell_wavefile);
+    write_setting_filename(sesskey, "BellWaveFile", cfg->bell_wavefile);
     write_setting_i(sesskey, "BellOverload", cfg->bellovl);
     write_setting_i(sesskey, "BellOverloadN", cfg->bellovl_n);
     write_setting_i(sesskey, "BellOverloadT", cfg->bellovl_t);
@@ -239,10 +277,7 @@ void save_settings(char *section, int do_host, Config * cfg)
     write_setting_s(sesskey, "WinTitle", cfg->wintitle);
     write_setting_i(sesskey, "TermWidth", cfg->width);
     write_setting_i(sesskey, "TermHeight", cfg->height);
-    write_setting_s(sesskey, "Font", cfg->font);
-    write_setting_i(sesskey, "FontIsBold", cfg->fontisbold);
-    write_setting_i(sesskey, "FontCharSet", cfg->fontcharset);
-    write_setting_i(sesskey, "FontHeight", cfg->fontheight);
+    write_setting_fontspec(sesskey, "Font", cfg->font);
     write_setting_i(sesskey, "FontVTMode", cfg->vtmode);
     write_setting_i(sesskey, "TryPalette", cfg->try_palette);
     write_setting_i(sesskey, "BoldAsColour", cfg->bold_colour);
@@ -276,11 +311,13 @@ void save_settings(char *section, int do_host, Config * cfg)
     write_setting_i(sesskey, "ScrollBarFullScreen", cfg->scrollbar_in_fullscreen);
     write_setting_i(sesskey, "ScrollOnKey", cfg->scroll_on_key);
     write_setting_i(sesskey, "ScrollOnDisp", cfg->scroll_on_disp);
+    write_setting_i(sesskey, "EraseToScrollback", cfg->erase_to_scrollback);
     write_setting_i(sesskey, "LockSize", cfg->resize_action);
     write_setting_i(sesskey, "BCE", cfg->bce);
     write_setting_i(sesskey, "BlinkText", cfg->blinktext);
     write_setting_i(sesskey, "X11Forward", cfg->x11_forward);
     write_setting_s(sesskey, "X11Display", cfg->x11_display);
+    write_setting_i(sesskey, "X11AuthType", cfg->x11_auth);
     write_setting_i(sesskey, "LocalPortAcceptAll", cfg->lport_acceptall);
     write_setting_i(sesskey, "RemotePortAcceptAll", cfg->rport_acceptall);
     {
@@ -302,28 +339,34 @@ void save_settings(char *section, int do_host, Config * cfg)
        *p = '\0';
        write_setting_s(sesskey, "PortForwardings", buf);
     }
-    write_setting_i(sesskey, "BugIgnore1", cfg->sshbug_ignore1);
-    write_setting_i(sesskey, "BugPlainPW1", cfg->sshbug_plainpw1);
-    write_setting_i(sesskey, "BugRSA1", cfg->sshbug_rsa1);
-    write_setting_i(sesskey, "BugHMAC2", cfg->sshbug_hmac2);
-    write_setting_i(sesskey, "BugDeriveKey2", cfg->sshbug_derivekey2);
-    write_setting_i(sesskey, "BugRSAPad2", cfg->sshbug_rsapad2);
-    write_setting_i(sesskey, "BugDHGEx2", cfg->sshbug_dhgex2);
+    write_setting_i(sesskey, "BugIgnore1", 2-cfg->sshbug_ignore1);
+    write_setting_i(sesskey, "BugPlainPW1", 2-cfg->sshbug_plainpw1);
+    write_setting_i(sesskey, "BugRSA1", 2-cfg->sshbug_rsa1);
+    write_setting_i(sesskey, "BugHMAC2", 2-cfg->sshbug_hmac2);
+    write_setting_i(sesskey, "BugDeriveKey2", 2-cfg->sshbug_derivekey2);
+    write_setting_i(sesskey, "BugRSAPad2", 2-cfg->sshbug_rsapad2);
+    write_setting_i(sesskey, "BugDHGEx2", 2-cfg->sshbug_dhgex2);
+    write_setting_i(sesskey, "BugPKSessID2", 2-cfg->sshbug_pksessid2);
     write_setting_i(sesskey, "StampUtmp", cfg->stamp_utmp);
     write_setting_i(sesskey, "LoginShell", cfg->login_shell);
     write_setting_i(sesskey, "ScrollbarOnLeft", cfg->scrollbar_on_left);
-    write_setting_s(sesskey, "BoldFont", cfg->boldfont);
+    write_setting_fontspec(sesskey, "BoldFont", cfg->boldfont);
     write_setting_i(sesskey, "ShadowBoldOffset", cfg->shadowboldoffset);
-    close_settings_w(sesskey);
 }
 
 void load_settings(char *section, int do_host, Config * cfg)
 {
-    int i;
-    char prot[10];
     void *sesskey;
 
     sesskey = open_settings_r(section);
+    load_open_settings(sesskey, do_host, cfg);
+    close_settings_r(sesskey);
+}
+
+void load_open_settings(void *sesskey, int do_host, Config *cfg)
+{
+    int i;
+    char prot[10];
 
     cfg->ssh_subsys = 0;              /* FIXME: load this properly */
     cfg->remote_cmd_ptr = cfg->remote_cmd;
@@ -334,8 +377,7 @@ void load_settings(char *section, int do_host, Config * cfg)
     } else {
        cfg->host[0] = '\0';           /* blank hostname */
     }
-    gpps(sesskey, "LogFileName", "putty.log",
-        cfg->logfilename, sizeof(cfg->logfilename));
+    gppfile(sesskey, "LogFileName", &cfg->logfilename);
     gppi(sesskey, "LogType", 0, &cfg->logtype);
     gppi(sesskey, "LogFileClash", LGXF_ASK, &cfg->logxfovr);
 
@@ -349,23 +391,9 @@ void load_settings(char *section, int do_host, Config * cfg)
            break;
        }
 
-    /*
-     * CloseOnExit defaults to closing only on a clean exit - but
-     * unfortunately not on Unix (pterm). On Unix, the exit code of
-     * a shell is the last exit code of one of its child processes,
-     * even if it's an interactive shell - so some pterms will
-     * close and some will not for no particularly good reason. The
-     * mode is still useful for specialist purposes (running a
-     * single command in its own pterm), but I don't think it's a
-     * sane default, unfortunately.
-     */
-    gppi(sesskey, "CloseOnExit",
-#ifdef _WINDOWS
-         COE_NORMAL,
-#else
-         COE_ALWAYS,
-#endif
-         &cfg->close_on_exit);
+    /* The CloseOnExit numbers are arranged in a different order from
+     * the standard FORCE_ON / FORCE_OFF / AUTO. */
+    gppi(sesskey, "CloseOnExit", 1, &i); cfg->close_on_exit = (i+1)%3;
     gppi(sesskey, "WarnOnClose", 1, &cfg->warn_on_close);
     {
        /* This is two values for backward compatibility with 0.50/0.51 */
@@ -383,7 +411,9 @@ void load_settings(char *section, int do_host, Config * cfg)
     /* proxy settings */
     gpps(sesskey, "ProxyExcludeList", "", cfg->proxy_exclude_list,
         sizeof(cfg->proxy_exclude_list));
-    gppi(sesskey, "ProxyType", PROXY_NONE, &i); cfg->proxy_type = i;
+    gppi(sesskey, "ProxyDNS", 1, &i); cfg->proxy_dns = (i+1)%3;
+    gppi(sesskey, "ProxyLocalhost", 0, &cfg->even_proxy_localhost);
+    gppi(sesskey, "ProxyType", PROXY_NONE, &cfg->proxy_type);
     gpps(sesskey, "ProxyHost", "proxy", cfg->proxy_host,
         sizeof(cfg->proxy_host));
     gppi(sesskey, "ProxyPort", 80, &cfg->proxy_port);
@@ -428,7 +458,7 @@ void load_settings(char *section, int do_host, Config * cfg)
     gppi(sesskey, "SSH2DES", 0, &cfg->ssh2_des_cbc);
     gppi(sesskey, "AuthTIS", 0, &cfg->try_tis_auth);
     gppi(sesskey, "AuthKI", 1, &cfg->try_ki_auth);
-    gpps(sesskey, "PublicKeyFile", "", cfg->keyfile, sizeof(cfg->keyfile));
+    gppfile(sesskey, "PublicKeyFile", &cfg->keyfile);
     gpps(sesskey, "RemoteCommand", "", cfg->remote_cmd,
         sizeof(cfg->remote_cmd));
     gppi(sesskey, "RFCEnviron", 0, &cfg->rfc_environ);
@@ -454,8 +484,8 @@ void load_settings(char *section, int do_host, Config * cfg)
     gppi(sesskey, "CtrlAltKeys", 1, &cfg->ctrlaltkeys);
     gppi(sesskey, "TelnetKey", 0, &cfg->telnet_keyboard);
     gppi(sesskey, "TelnetRet", 1, &cfg->telnet_newline);
-    gppi(sesskey, "LocalEcho", LD_BACKEND, &cfg->localecho);
-    gppi(sesskey, "LocalEdit", LD_BACKEND, &cfg->localedit);
+    gppi(sesskey, "LocalEcho", AUTO, &cfg->localecho);
+    gppi(sesskey, "LocalEdit", AUTO, &cfg->localedit);
     gpps(sesskey, "Answerback", "PuTTY", cfg->answerback,
         sizeof(cfg->answerback));
     gppi(sesskey, "AlwaysOnTop", 0, &cfg->alwaysontop);
@@ -466,10 +496,9 @@ void load_settings(char *section, int do_host, Config * cfg)
     gppi(sesskey, "CurType", 0, &cfg->cursor_type);
     gppi(sesskey, "BlinkCur", 0, &cfg->blink_cur);
     /* pedantic compiler tells me I can't use &cfg->beep as an int * :-) */
-    gppi(sesskey, "Beep", 1, &i); cfg->beep = i;
-    gppi(sesskey, "BeepInd", 0, &i); cfg->beep_ind = i;
-    gpps(sesskey, "BellWaveFile", "", cfg->bell_wavefile,
-        sizeof(cfg->bell_wavefile));
+    gppi(sesskey, "Beep", 1, &cfg->beep);
+    gppi(sesskey, "BeepInd", 0, &cfg->beep_ind);
+    gppfile(sesskey, "BellWaveFile", &cfg->bell_wavefile);
     gppi(sesskey, "BellOverload", 1, &cfg->bellovl);
     gppi(sesskey, "BellOverloadN", 5, &cfg->bellovl_n);
     gppi(sesskey, "BellOverloadT", 2*TICKSPERSEC, &cfg->bellovl_t);
@@ -478,39 +507,16 @@ void load_settings(char *section, int do_host, Config * cfg)
     gppi(sesskey, "DECOriginMode", 0, &cfg->dec_om);
     gppi(sesskey, "AutoWrapMode", 1, &cfg->wrap_mode);
     gppi(sesskey, "LFImpliesCR", 0, &cfg->lfhascr);
-    gppi(sesskey, "WinNameAlways", 0, &cfg->win_name_always);
+    gppi(sesskey, "WinNameAlways", 1, &cfg->win_name_always);
     gpps(sesskey, "WinTitle", "", cfg->wintitle, sizeof(cfg->wintitle));
     gppi(sesskey, "TermWidth", 80, &cfg->width);
     gppi(sesskey, "TermHeight", 24, &cfg->height);
-#ifdef _WINDOWS
-    gpps(sesskey, "Font", "Courier New", cfg->font, sizeof(cfg->font));
-#else
-    gpps(sesskey, "Font", "fixed", cfg->font, sizeof(cfg->font));
-#endif
-    gppi(sesskey, "FontIsBold", 0, &cfg->fontisbold);
-#ifdef _WINDOWS
-    gppi(sesskey, "FontCharSet", ANSI_CHARSET, &cfg->fontcharset);
-#endif
-    gppi(sesskey, "FontHeight", 10, &cfg->fontheight);
-#ifdef _WINDOWS
-    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;
-    }
-#endif
+    gppfont(sesskey, "Font", &cfg->font);
     gppi(sesskey, "FontVTMode", VT_UNICODE, (int *) &cfg->vtmode);
     gppi(sesskey, "TryPalette", 0, &cfg->try_palette);
     gppi(sesskey, "BoldAsColour", 1, &cfg->bold_colour);
     for (i = 0; i < 22; i++) {
-       static char *defaults[] = {
+       static const char *const defaults[] = {
            "187,187,187", "255,255,255", "0,0,0", "85,85,85", "0,0,0",
            "0,255,0", "0,0,0", "85,85,85", "187,0,0", "255,85,85",
            "0,187,0", "85,255,85", "187,187,0", "255,255,85", "0,0,187",
@@ -527,22 +533,13 @@ void load_settings(char *section, int do_host, Config * cfg)
            cfg->colours[i][2] = c2;
        }
     }
-#ifndef _WINDOWS
-    /* Non-raw cut and paste of line-drawing chars works badly on the
-     * current Unix stub implementation of the Unicode functions.
-     * So I'm going to temporarily set the default to raw mode so
-     * that the failure mode isn't quite so drastically horrid.
-     * When Unicode comes in, this can all be put right. */
-    gppi(sesskey, "RawCNP", 1, &cfg->rawcnp);
-#else
     gppi(sesskey, "RawCNP", 0, &cfg->rawcnp);
-#endif
     gppi(sesskey, "PasteRTF", 0, &cfg->rtf_paste);
     gppi(sesskey, "MouseIsXterm", 0, &cfg->mouse_is_xterm);
     gppi(sesskey, "RectSelect", 0, &cfg->rect_select);
     gppi(sesskey, "MouseOverride", 1, &cfg->mouse_override);
     for (i = 0; i < 256; i += 32) {
-       static char *defaults[] = {
+       static const char *const defaults[] = {
            "0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0",
            "0,1,2,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,2,2,2,1,1,1,1,1,1",
            "1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,1,1,1,1,2",
@@ -578,12 +575,14 @@ void load_settings(char *section, int do_host, Config * cfg)
     gppi(sesskey, "ScrollBarFullScreen", 0, &cfg->scrollbar_in_fullscreen);
     gppi(sesskey, "ScrollOnKey", 0, &cfg->scroll_on_key);
     gppi(sesskey, "ScrollOnDisp", 1, &cfg->scroll_on_disp);
-    gppi(sesskey, "LockSize", 0, &i); cfg->resize_action = i;
+    gppi(sesskey, "EraseToScrollback", 1, &cfg->erase_to_scrollback);
+    gppi(sesskey, "LockSize", 0, &cfg->resize_action);
     gppi(sesskey, "BCE", 1, &cfg->bce);
     gppi(sesskey, "BlinkText", 0, &cfg->blinktext);
     gppi(sesskey, "X11Forward", 0, &cfg->x11_forward);
     gpps(sesskey, "X11Display", "localhost:0", cfg->x11_display,
         sizeof(cfg->x11_display));
+    gppi(sesskey, "X11AuthType", X11_MIT, &cfg->x11_auth);
 
     gppi(sesskey, "LocalPortAcceptAll", 0, &cfg->lport_acceptall);
     gppi(sesskey, "RemotePortAcceptAll", 0, &cfg->rport_acceptall);
@@ -607,36 +606,34 @@ void load_settings(char *section, int do_host, Config * cfg)
        }
        *q = '\0';
     }
-    gppi(sesskey, "BugIgnore1", BUG_AUTO, &i); cfg->sshbug_ignore1 = i;
-    gppi(sesskey, "BugPlainPW1", BUG_AUTO, &i); cfg->sshbug_plainpw1 = i;
-    gppi(sesskey, "BugRSA1", BUG_AUTO, &i); cfg->sshbug_rsa1 = i;
+    gppi(sesskey, "BugIgnore1", 0, &i); cfg->sshbug_ignore1 = 2-i;
+    gppi(sesskey, "BugPlainPW1", 0, &i); cfg->sshbug_plainpw1 = 2-i;
+    gppi(sesskey, "BugRSA1", 0, &i); cfg->sshbug_rsa1 = 2-i;
     {
        int i;
-       gppi(sesskey, "BugHMAC2", BUG_AUTO, &i); cfg->sshbug_hmac2 = i;
-       if (cfg->sshbug_hmac2 == BUG_AUTO) {
+       gppi(sesskey, "BugHMAC2", 0, &i); cfg->sshbug_hmac2 = 2-i;
+       if (cfg->sshbug_hmac2 == AUTO) {
            gppi(sesskey, "BuggyMAC", 0, &i);
            if (i == 1)
-               cfg->sshbug_hmac2 = BUG_ON;
+               cfg->sshbug_hmac2 = FORCE_ON;
        }
     }
-    gppi(sesskey, "BugDeriveKey2", BUG_AUTO, &i); cfg->sshbug_derivekey2 = i;
-    gppi(sesskey, "BugRSAPad2", BUG_AUTO, &i); cfg->sshbug_rsapad2 = i;
-    gppi(sesskey, "BugDHGEx2", BUG_AUTO, &i); cfg->sshbug_dhgex2 = i;
+    gppi(sesskey, "BugDeriveKey2", 0, &i); cfg->sshbug_derivekey2 = 2-i;
+    gppi(sesskey, "BugRSAPad2", 0, &i); cfg->sshbug_rsapad2 = 2-i;
+    gppi(sesskey, "BugDHGEx2", 0, &i); cfg->sshbug_dhgex2 = 2-i;
+    gppi(sesskey, "BugPKSessID2", 0, &i); cfg->sshbug_pksessid2 = 2-i;
     gppi(sesskey, "StampUtmp", 1, &cfg->stamp_utmp);
     gppi(sesskey, "LoginShell", 1, &cfg->login_shell);
     gppi(sesskey, "ScrollbarOnLeft", 0, &cfg->scrollbar_on_left);
-    gpps(sesskey, "BoldFont", "", cfg->boldfont, sizeof(cfg->boldfont));
+    gppfont(sesskey, "BoldFont", &cfg->boldfont);
+    gppfont(sesskey, "WideFont", &cfg->widefont);
+    gppfont(sesskey, "WideBoldFont", &cfg->wideboldfont);
     gppi(sesskey, "ShadowBoldOffset", 1, &cfg->shadowboldoffset);
-
-    close_settings_r(sesskey);
 }
 
 void do_defaults(char *session, Config * cfg)
 {
-    if (session)
-       load_settings(session, TRUE, cfg);
-    else
-       load_settings("Default Settings", FALSE, cfg);
+    load_settings(session, (session != NULL && *session), cfg);
 }
 
 static int sessioncmp(const void *av, const void *bv)
@@ -677,7 +674,7 @@ void get_sesslist(struct sesslist *list, int allocate)
                    int len = strlen(otherbuf) + 1;
                    if (bufsize < buflen + len) {
                        bufsize = buflen + len + 2048;
-                       list->buffer = srealloc(list->buffer, bufsize);
+                       list->buffer = sresize(list->buffer, bufsize, char);
                    }
                    strcpy(list->buffer + buflen, otherbuf);
                    buflen += strlen(list->buffer + buflen) + 1;
@@ -685,7 +682,7 @@ void get_sesslist(struct sesslist *list, int allocate)
            } while (ret);
            enum_settings_finish(handle);
        }
-       list->buffer = srealloc(list->buffer, buflen + 1);
+       list->buffer = sresize(list->buffer, buflen + 1, char);
        list->buffer[buflen] = '\0';
 
        /*
@@ -704,7 +701,7 @@ void get_sesslist(struct sesslist *list, int allocate)
            p++;
        }
 
-       list->sessions = smalloc((list->nsessions + 1) * sizeof(char *));
+       list->sessions = snewn(list->nsessions + 1, char *);
        list->sessions[0] = "Default Settings";
        p = list->buffer;
        i = 1;