mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-03-22 14:39:24 -05:00
Fix a batch of resource leaks spotted by Coverity.
This commit is contained in:
parent
16d5bb7269
commit
1f6d93f0c8
@ -1242,12 +1242,12 @@ ptrlen ntru_decode_pubkey(uint16_t *pubkey, unsigned p, unsigned q,
|
|||||||
} else {
|
} else {
|
||||||
/* Do the decoding */
|
/* Do the decoding */
|
||||||
ntru_decode(sched, pubkey, encoded);
|
ntru_decode(sched, pubkey, encoded);
|
||||||
ntru_encode_schedule_free(sched);
|
|
||||||
|
|
||||||
/* Unbias the coefficients */
|
/* Unbias the coefficients */
|
||||||
ntru_bias(pubkey, pubkey, q-q/2, p, q);
|
ntru_bias(pubkey, pubkey, q-q/2, p, q);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ntru_encode_schedule_free(sched);
|
||||||
return encoded;
|
return encoded;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1328,13 +1328,13 @@ ptrlen ntru_decode_ciphertext(uint16_t *ct, NTRUKeyPair *keypair,
|
|||||||
} else {
|
} else {
|
||||||
/* Do the decoding */
|
/* Do the decoding */
|
||||||
ntru_decode(sched, ct, encoded);
|
ntru_decode(sched, ct, encoded);
|
||||||
ntru_encode_schedule_free(sched);
|
|
||||||
|
|
||||||
/* Undo the scaling and bias */
|
/* Undo the scaling and bias */
|
||||||
ntru_scale(ct, ct, 3, p, q);
|
ntru_scale(ct, ct, 3, p, q);
|
||||||
ntru_bias(ct, ct, q - 3 * ciphertext_bias(q), p, q);
|
ntru_bias(ct, ct, q - 3 * ciphertext_bias(q), p, q);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ntru_encode_schedule_free(sched);
|
||||||
return encoded; /* also useful to the caller, optionally */
|
return encoded; /* also useful to the caller, optionally */
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1649,6 +1649,7 @@ static bool ssh_ntru_client_getkey(ecdh_key *dh, ptrlen remoteKey,
|
|||||||
if (!ok) {
|
if (!ok) {
|
||||||
ssh_hash_free(h);
|
ssh_hash_free(h);
|
||||||
smemclr(hashdata, sizeof(hashdata));
|
smemclr(hashdata, sizeof(hashdata));
|
||||||
|
strbuf_free(otherkey);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1778,6 +1779,7 @@ static bool ssh_ntru_server_getkey(ecdh_key *dh, ptrlen remoteKey,
|
|||||||
ntru_encrypt(ciphertext, nk->plaintext, pubkey, p_LIVE, q_LIVE);
|
ntru_encrypt(ciphertext, nk->plaintext, pubkey, p_LIVE, q_LIVE);
|
||||||
ntru_encode_ciphertext(ciphertext, p_LIVE, q_LIVE,
|
ntru_encode_ciphertext(ciphertext, p_LIVE, q_LIVE,
|
||||||
BinarySink_UPCAST(nk->ciphertext_encoded));
|
BinarySink_UPCAST(nk->ciphertext_encoded));
|
||||||
|
ring_free(ciphertext, p_LIVE);
|
||||||
|
|
||||||
/* Compute the confirmation hash, and write it into another
|
/* Compute the confirmation hash, and write it into another
|
||||||
* strbuf. */
|
* strbuf. */
|
||||||
@ -1793,6 +1795,9 @@ static bool ssh_ntru_server_getkey(ecdh_key *dh, ptrlen remoteKey,
|
|||||||
|
|
||||||
/* And put the NTRU session hash into the main hash object. */
|
/* And put the NTRU session hash into the main hash object. */
|
||||||
put_data(h, hashdata, 32);
|
put_data(h, hashdata, 32);
|
||||||
|
|
||||||
|
/* Now we can free the public key */
|
||||||
|
ring_free(pubkey, p_LIVE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -1809,6 +1814,7 @@ static bool ssh_ntru_server_getkey(ecdh_key *dh, ptrlen remoteKey,
|
|||||||
if (!ok) {
|
if (!ok) {
|
||||||
ssh_hash_free(h);
|
ssh_hash_free(h);
|
||||||
smemclr(hashdata, sizeof(hashdata));
|
smemclr(hashdata, sizeof(hashdata));
|
||||||
|
strbuf_free(otherkey);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -962,6 +962,7 @@ void ssh2kex_coroutine(struct ssh2_transport_state *s, bool *aborted)
|
|||||||
} else {
|
} else {
|
||||||
ppl_logevent("Rejected host key certificate: %s",
|
ppl_logevent("Rejected host key certificate: %s",
|
||||||
error->s);
|
error->s);
|
||||||
|
strbuf_free(error);
|
||||||
/* now fall through into normal host key checking */
|
/* now fall through into normal host key checking */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -679,6 +679,8 @@ host_ca *host_ca_load(const char *name)
|
|||||||
sfree(line);
|
sfree(line);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fclose(fp);
|
||||||
|
|
||||||
if (eb) {
|
if (eb) {
|
||||||
if (!hca->validity_expression) {
|
if (!hca->validity_expression) {
|
||||||
hca->validity_expression = cert_expr_expression(eb);
|
hca->validity_expression = cert_expr_expression(eb);
|
||||||
|
@ -1256,6 +1256,7 @@ void add_certificate(HWND hwnd, struct MainDlgState *state,
|
|||||||
message_box(hwnd, msg, "PuTTYgen Error", MB_OK | MB_ICONERROR,
|
message_box(hwnd, msg, "PuTTYgen Error", MB_OK | MB_ICONERROR,
|
||||||
HELPCTXID(errors_cantloadkey));
|
HELPCTXID(errors_cantloadkey));
|
||||||
sfree(msg);
|
sfree(msg);
|
||||||
|
strbuf_free(pub);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user