mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-28 14:23:30 +01:00
Fix memory leaks in hs_descriptor/decode_descriptor and in encode_enc_key()
This commit is contained in:
parent
a4291eef5a
commit
d16b4b3e48
@ -270,7 +270,7 @@ encode_enc_key(const ed25519_keypair_t *sig_key,
|
|||||||
char *key_str, b64_cert[256];
|
char *key_str, b64_cert[256];
|
||||||
ssize_t cert_len;
|
ssize_t cert_len;
|
||||||
size_t key_str_len;
|
size_t key_str_len;
|
||||||
uint8_t *cert_data;
|
uint8_t *cert_data = NULL;
|
||||||
|
|
||||||
/* Create cross certification cert. */
|
/* Create cross certification cert. */
|
||||||
cert_len = tor_make_rsa_ed25519_crosscert(&sig_key->pubkey,
|
cert_len = tor_make_rsa_ed25519_crosscert(&sig_key->pubkey,
|
||||||
@ -284,9 +284,11 @@ encode_enc_key(const ed25519_keypair_t *sig_key,
|
|||||||
/* Encode cross cert. */
|
/* Encode cross cert. */
|
||||||
if (base64_encode(b64_cert, sizeof(b64_cert), (const char *) cert_data,
|
if (base64_encode(b64_cert, sizeof(b64_cert), (const char *) cert_data,
|
||||||
cert_len, BASE64_ENCODE_MULTILINE) < 0) {
|
cert_len, BASE64_ENCODE_MULTILINE) < 0) {
|
||||||
|
tor_free(cert_data);
|
||||||
log_warn(LD_REND, "Unable to encode legacy crosscert.");
|
log_warn(LD_REND, "Unable to encode legacy crosscert.");
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
tor_free(cert_data);
|
||||||
/* Convert the encryption key to a string. */
|
/* Convert the encryption key to a string. */
|
||||||
if (crypto_pk_write_public_key_to_string(ip->enc_key.legacy, &key_str,
|
if (crypto_pk_write_public_key_to_string(ip->enc_key.legacy, &key_str,
|
||||||
&key_str_len) < 0) {
|
&key_str_len) < 0) {
|
||||||
|
@ -498,6 +498,7 @@ test_decode_descriptor(void *arg)
|
|||||||
char *encoded = NULL;
|
char *encoded = NULL;
|
||||||
hs_descriptor_t *desc = helper_build_hs_desc(0);
|
hs_descriptor_t *desc = helper_build_hs_desc(0);
|
||||||
hs_descriptor_t *decoded = NULL;
|
hs_descriptor_t *decoded = NULL;
|
||||||
|
hs_descriptor_t *desc_no_ip = NULL;
|
||||||
|
|
||||||
(void) arg;
|
(void) arg;
|
||||||
|
|
||||||
@ -517,7 +518,7 @@ test_decode_descriptor(void *arg)
|
|||||||
|
|
||||||
/* Decode a descriptor with _no_ introduction points. */
|
/* Decode a descriptor with _no_ introduction points. */
|
||||||
{
|
{
|
||||||
hs_descriptor_t *desc_no_ip = helper_build_hs_desc(1);
|
desc_no_ip = helper_build_hs_desc(1);
|
||||||
tt_assert(desc_no_ip);
|
tt_assert(desc_no_ip);
|
||||||
tor_free(encoded);
|
tor_free(encoded);
|
||||||
ret = hs_desc_encode_descriptor(desc_no_ip, &encoded);
|
ret = hs_desc_encode_descriptor(desc_no_ip, &encoded);
|
||||||
@ -531,6 +532,7 @@ test_decode_descriptor(void *arg)
|
|||||||
|
|
||||||
done:
|
done:
|
||||||
hs_descriptor_free(desc);
|
hs_descriptor_free(desc);
|
||||||
|
hs_descriptor_free(desc_no_ip);
|
||||||
hs_descriptor_free(decoded);
|
hs_descriptor_free(decoded);
|
||||||
tor_free(encoded);
|
tor_free(encoded);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user