X-Git-Url: https://git.distorted.org.uk/u/mdw/putty/blobdiff_plain/038ec85e825fc940c1387f64a88ae73b75f6822b..88ea89339783ee587180b645981967f6cb8bcd20:/import.c diff --git a/import.c b/import.c index d4b87bc7..bc35a4ab 100644 --- a/import.c +++ b/import.c @@ -372,6 +372,7 @@ static struct openssh_key *load_openssh_key(const Filename *filename, if (0 == strncmp(line, "-----END ", 9) && 0 == strcmp(line+strlen(line)-16, "PRIVATE KEY-----")) { sfree(line); + line = NULL; break; /* done */ } if ((p = strchr(line, ':')) != NULL) { @@ -1095,6 +1096,7 @@ static struct sshcom_key *load_sshcom_key(const Filename *filename, strip_crlf(line); if (!strcmp(line, "---- END SSH2 ENCRYPTED PRIVATE KEY ----")) { sfree(line); + line = NULL; break; /* done */ } if ((p = strchr(line, ':')) != NULL) { @@ -1245,11 +1247,15 @@ int sshcom_encrypted(const Filename *filename, char **comment) answer = 1; done: - *comment = dupstr(key ? key->comment : ""); - smemclr(key->keyblob, key->keyblob_size); - sfree(key->keyblob); - smemclr(key, sizeof(*key)); - sfree(key); + if (key) { + *comment = dupstr(key->comment); + smemclr(key->keyblob, key->keyblob_size); + sfree(key->keyblob); + smemclr(key, sizeof(*key)); + sfree(key); + } else { + *comment = dupstr(""); + } return answer; } @@ -1473,9 +1479,12 @@ struct ssh2_userkey *sshcom_read(const Filename *filename, char *passphrase, pos += put_mp(blob+pos, p.start, p.bytes); pos += put_mp(blob+pos, u.start, u.bytes); privlen = pos - publen; - } else if (type == DSA) { + } else { struct mpint_pos p, q, g, x, y; int pos = 4; + + assert(type == DSA); /* the only other option from the if above */ + if (GET_32BIT(ciphertext) != 0) { errmsg = "predefined DSA parameters not supported"; goto error; @@ -1500,8 +1509,7 @@ struct ssh2_userkey *sshcom_read(const Filename *filename, char *passphrase, publen = pos; pos += put_mp(blob+pos, x.start, x.bytes); privlen = pos - publen; - } else - return NULL; + } assert(privlen > 0); /* should have bombed by now if not */