1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-06-30 19:12:48 -05:00

Move some manual freeing into freersakey().

Several pieces of old code were disposing of pieces of an RSAKey by
manually freeing them one at a time. We have a centralised
freersakey(), so we should use that instead wherever possible.

Where it wasn't possible to switch over to that, it was because we
were only freeing the private fields of the key - so I've fixed that
by cutting freersakey() down the middle and exposing the private-only
half as freersapriv().
This commit is contained in:
Simon Tatham
2018-12-14 19:42:47 +00:00
parent 55cea187e9
commit a80edab4b5
4 changed files with 38 additions and 34 deletions

View File

@ -308,8 +308,7 @@ void pageant_handle_msg(BinarySink *bs,
if (response)
freebn(response);
freebn(challenge);
freebn(reqkey.exponent);
freebn(reqkey.modulus);
freersakey(&reqkey);
}
break;
case SSH2_AGENTC_SIGN_REQUEST:
@ -526,13 +525,13 @@ void pageant_handle_msg(BinarySink *bs,
plog(logctx, logfn, "request: SSH1_AGENTC_REMOVE_RSA_IDENTITY");
memset(&reqkey, 0, sizeof(reqkey));
get_rsa_ssh1_pub(msg, &reqkey, RSA_SSH1_EXPONENT_FIRST);
if (get_err(msg)) {
pageant_failure_msg(bs, "unable to decode request",
logctx, logfn);
freebn(reqkey.exponent);
freebn(reqkey.modulus);
freersakey(&reqkey);
return;
}
@ -545,8 +544,7 @@ void pageant_handle_msg(BinarySink *bs,
}
key = find234(rsakeys, &reqkey, NULL);
freebn(reqkey.exponent);
freebn(reqkey.modulus);
freersakey(&reqkey);
if (key) {
plog(logctx, logfn, "found with comment: %s", key->comment);