X-Git-Url: https://asedeno.scripts.mit.edu/gitweb/?a=blobdiff_plain;f=cmdline.c;h=327a585a4580ed0ebada38e63a3059cb8108142a;hb=068b67d2f6e9b186b3107ebcb1e88a141b7b5ebc;hp=cf114c0ea026b70f63b0c17e4063237bbcbb1435;hpb=31fd55edf1c69aa01305b5ad55143a86ad75be0d;p=PuTTY.git diff --git a/cmdline.c b/cmdline.c index cf114c0e..327a585a 100644 --- a/cmdline.c +++ b/cmdline.c @@ -63,7 +63,7 @@ void cmdline_cleanup(void) int pri; if (cmdline_password) { - memset(cmdline_password, 0, strlen(cmdline_password)); + smemclr(cmdline_password, strlen(cmdline_password)); sfree(cmdline_password); cmdline_password = NULL; } @@ -105,15 +105,12 @@ int cmdline_get_passwd_input(prompts_t *p, unsigned char *in, int inlen) { if (tried_once) return 0; - strncpy(p->prompts[0]->result, cmdline_password, - p->prompts[0]->result_len); - p->prompts[0]->result[p->prompts[0]->result_len-1] = '\0'; - memset(cmdline_password, 0, strlen(cmdline_password)); + prompt_set_result(p->prompts[0], cmdline_password); + smemclr(cmdline_password, strlen(cmdline_password)); sfree(cmdline_password); cmdline_password = NULL; tried_once = 1; return 1; - } /* @@ -239,6 +236,21 @@ int cmdline_process_param(char *p, char *value, int need_save, Conf *conf) SAVEABLE(0); conf_set_str(conf, CONF_loghost, value); } + if (!strcmp(p, "-hostkey")) { + char *dup; + RETURN(2); + UNAVAILABLE_IN(TOOLTYPE_NONNETWORK); + SAVEABLE(0); + dup = dupstr(value); + if (!validate_manual_hostkey(dup)) { + cmdline_error("'%s' is not a valid format for a manual host " + "key specification", value); + sfree(dup); + return ret; + } + conf_set_str_str(conf, CONF_ssh_manual_hostkeys, dup, ""); + sfree(dup); + } if ((!strcmp(p, "-L") || !strcmp(p, "-R") || !strcmp(p, "-D"))) { char type, *q, *qq, *key, *val; RETURN(2); @@ -264,9 +276,9 @@ int cmdline_process_param(char *p, char *value, int need_save, Conf *conf) type = p[1]; /* 'L' or 'R' */ - q = qq = strchr(value, ':'); + q = qq = host_strchr(value, ':'); while (qq) { - char *qqq = strchr(qq+1, ':'); + char *qqq = host_strchr(qq+1, ':'); if (qqq) q = qq; qq = qqq; @@ -278,7 +290,7 @@ int cmdline_process_param(char *p, char *value, int need_save, Conf *conf) return ret; } - key = dupprintf("%c%.*s", type, q - value, value); + key = dupprintf("%c%.*s", type, (int)(q - value), value); val = dupstr(q+1); } else { /* @@ -304,13 +316,13 @@ int cmdline_process_param(char *p, char *value, int need_save, Conf *conf) UNAVAILABLE_IN(TOOLTYPE_FILETRANSFER | TOOLTYPE_NONNETWORK); SAVEABLE(0); - portp = strchr(value, ':'); + portp = host_strchr(value, ':'); if (!portp) { cmdline_error("-nc expects argument of form 'host:port'"); return ret; } - host = dupprintf("%.*s", portp - value, value); + host = dupprintf("%.*s", (int)(portp - value), value); conf_set_str(conf, CONF_ssh_nc_host, host); conf_set_int(conf, CONF_ssh_nc_port, atoi(portp + 1)); sfree(host); @@ -371,7 +383,7 @@ int cmdline_process_param(char *p, char *value, int need_save, Conf *conf) /* Assuming that `value' is directly from argv, make a good faith * attempt to trample it, to stop it showing up in `ps' output * on Unix-like systems. Not guaranteed, of course. */ - memset(value, 0, strlen(value)); + smemclr(value, strlen(value)); } } @@ -457,12 +469,13 @@ int cmdline_process_param(char *p, char *value, int need_save, Conf *conf) } if (!strcmp(p, "-i")) { - Filename fn; + Filename *fn; RETURN(2); UNAVAILABLE_IN(TOOLTYPE_NONNETWORK); SAVEABLE(0); fn = filename_from_str(value); - conf_set_filename(conf, CONF_keyfile, &fn); + conf_set_filename(conf, CONF_keyfile, fn); + filename_free(fn); } if (!strcmp(p, "-4") || !strcmp(p, "-ipv4")) { @@ -504,6 +517,10 @@ int cmdline_process_param(char *p, char *value, int need_save, Conf *conf) break; case '5': + case '6': + case '7': + case '8': + case '9': conf_set_int(conf, CONF_serdatabits, *nextitem-'0'); break;