X-Git-Url: https://git.distorted.org.uk/u/mdw/putty/blobdiff_plain/9621bbab1023b211d1ab0ee2f1039b0462b55812..735a4294762b784c878bc249f591be8fd154c237:/cmdline.c diff --git a/cmdline.c b/cmdline.c index aafb6900..bfb2b426 100644 --- a/cmdline.c +++ b/cmdline.c @@ -56,20 +56,30 @@ static void cmdline_save_param(char *p, char *value, int pri) saves[pri].nsaved++; } +static char *cmdline_password = NULL; + void cmdline_cleanup(void) { int pri; - for (pri = 0; pri < NPRIORITIES; pri++) + if (cmdline_password) { + memset(cmdline_password, 0, strlen(cmdline_password)); + sfree(cmdline_password); + cmdline_password = NULL; + } + + for (pri = 0; pri < NPRIORITIES; pri++) { sfree(saves[pri].params); + saves[pri].params = NULL; + saves[pri].savesize = 0; + saves[pri].nsaved = 0; + } } #define SAVEABLE(pri) do { \ if (need_save) { cmdline_save_param(p, value, pri); return ret; } \ } while (0) -static char *cmdline_password = NULL; - /* * Similar interface to get_userpass_input(), except that here a -1 * return means that we aren't capable of processing the prompt and @@ -99,6 +109,8 @@ int cmdline_get_passwd_input(prompts_t *p, unsigned char *in, int inlen) { p->prompts[0]->result_len); p->prompts[0]->result[p->prompts[0]->result_len-1] = '\0'; memset(cmdline_password, 0, strlen(cmdline_password)); + sfree(cmdline_password); + cmdline_password = NULL; tried_once = 1; return 1; @@ -160,6 +172,7 @@ int cmdline_process_param(char *p, char *value, int need_save, Config *cfg) * saved. */ do_defaults(value, cfg); loaded_session = TRUE; + cmdline_session_name = dupstr(value); return 2; } if (!strcmp(p, "-ssh")) { @@ -322,6 +335,7 @@ int cmdline_process_param(char *p, char *value, int need_save, Config *cfg) cfg->remote_cmd_ptr = command; cfg->remote_cmd_ptr2 = NULL; cfg->nopty = TRUE; /* command => no terminal */ + fclose(fp); } if (!strcmp(p, "-P")) { RETURN(2);