1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-01-09 17:38:00 +00:00

sshecc.c: reliably initialise ek->privateKey.

If something goes wrong part way through one of the new-key functions,
we immediately call the corresponding freekey function before
returning failure. That will test ek->privateKey for NULL, and if it's
not NULL, try to free it - so we should be sure it _is_ NULL if we
haven't put a private key in it.
This commit is contained in:
Simon Tatham 2019-02-04 20:12:50 +00:00
parent 961c39ccd0
commit 7a9eb02e47

View File

@ -567,6 +567,7 @@ static ssh_key *ecdsa_new_pub(const ssh_keyalg *alg, ptrlen data)
struct ecdsa_key *ek = snew(struct ecdsa_key);
ek->sshk.vt = alg;
ek->curve = curve;
ek->privateKey = NULL;
ek->publicKey = get_wpoint(src, curve);
if (!ek->publicKey) {
@ -574,8 +575,6 @@ static ssh_key *ecdsa_new_pub(const ssh_keyalg *alg, ptrlen data)
return NULL;
}
ek->privateKey = NULL;
return &ek->sshk;
}
@ -742,6 +741,7 @@ static ssh_key *eddsa_new_priv_openssh(
struct eddsa_key *ek = snew(struct eddsa_key);
ek->sshk.vt = alg;
ek->curve = curve;
ek->privateKey = NULL;
ek->publicKey = eddsa_decode(pubkey_pl, curve);
if (!ek->publicKey) {
@ -793,6 +793,7 @@ static ssh_key *ecdsa_new_priv_openssh(
struct eddsa_key *ek = snew(struct eddsa_key);
ek->sshk.vt = alg;
ek->curve = curve;
ek->privateKey = NULL;
ek->publicKey = get_epoint(src, curve);
if (!ek->publicKey) {