mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-01-10 01:48: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:
parent
961c39ccd0
commit
7a9eb02e47
5
sshecc.c
5
sshecc.c
@ -567,6 +567,7 @@ static ssh_key *ecdsa_new_pub(const ssh_keyalg *alg, ptrlen data)
|
|||||||
struct ecdsa_key *ek = snew(struct ecdsa_key);
|
struct ecdsa_key *ek = snew(struct ecdsa_key);
|
||||||
ek->sshk.vt = alg;
|
ek->sshk.vt = alg;
|
||||||
ek->curve = curve;
|
ek->curve = curve;
|
||||||
|
ek->privateKey = NULL;
|
||||||
|
|
||||||
ek->publicKey = get_wpoint(src, curve);
|
ek->publicKey = get_wpoint(src, curve);
|
||||||
if (!ek->publicKey) {
|
if (!ek->publicKey) {
|
||||||
@ -574,8 +575,6 @@ static ssh_key *ecdsa_new_pub(const ssh_keyalg *alg, ptrlen data)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
ek->privateKey = NULL;
|
|
||||||
|
|
||||||
return &ek->sshk;
|
return &ek->sshk;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -742,6 +741,7 @@ static ssh_key *eddsa_new_priv_openssh(
|
|||||||
struct eddsa_key *ek = snew(struct eddsa_key);
|
struct eddsa_key *ek = snew(struct eddsa_key);
|
||||||
ek->sshk.vt = alg;
|
ek->sshk.vt = alg;
|
||||||
ek->curve = curve;
|
ek->curve = curve;
|
||||||
|
ek->privateKey = NULL;
|
||||||
|
|
||||||
ek->publicKey = eddsa_decode(pubkey_pl, curve);
|
ek->publicKey = eddsa_decode(pubkey_pl, curve);
|
||||||
if (!ek->publicKey) {
|
if (!ek->publicKey) {
|
||||||
@ -793,6 +793,7 @@ static ssh_key *ecdsa_new_priv_openssh(
|
|||||||
struct eddsa_key *ek = snew(struct eddsa_key);
|
struct eddsa_key *ek = snew(struct eddsa_key);
|
||||||
ek->sshk.vt = alg;
|
ek->sshk.vt = alg;
|
||||||
ek->curve = curve;
|
ek->curve = curve;
|
||||||
|
ek->privateKey = NULL;
|
||||||
|
|
||||||
ek->publicKey = get_epoint(src, curve);
|
ek->publicKey = get_epoint(src, curve);
|
||||||
if (!ek->publicKey) {
|
if (!ek->publicKey) {
|
||||||
|
Loading…
Reference in New Issue
Block a user