aboutsummaryrefslogtreecommitdiff
path: root/src/or/hs_descriptor.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2016-11-04 14:27:45 -0400
committerNick Mathewson <nickm@torproject.org>2016-11-04 14:27:45 -0400
commitd16b4b3e485526b39e7bdc36bf2d8041080a7201 (patch)
treecc0f2f7299a2f928b82bffceea36515ef8c8e914 /src/or/hs_descriptor.c
parenta4291eef5aeeb9ba8939b563a657ac50d4447b7e (diff)
downloadtor-d16b4b3e485526b39e7bdc36bf2d8041080a7201.tar.gz
tor-d16b4b3e485526b39e7bdc36bf2d8041080a7201.zip
Fix memory leaks in hs_descriptor/decode_descriptor and in encode_enc_key()
Diffstat (limited to 'src/or/hs_descriptor.c')
-rw-r--r--src/or/hs_descriptor.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/or/hs_descriptor.c b/src/or/hs_descriptor.c
index 668862f902..92e523e37d 100644
--- a/src/or/hs_descriptor.c
+++ b/src/or/hs_descriptor.c
@@ -270,7 +270,7 @@ encode_enc_key(const ed25519_keypair_t *sig_key,
char *key_str, b64_cert[256];
ssize_t cert_len;
size_t key_str_len;
- uint8_t *cert_data;
+ uint8_t *cert_data = NULL;
/* Create cross certification cert. */
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. */
if (base64_encode(b64_cert, sizeof(b64_cert), (const char *) cert_data,
cert_len, BASE64_ENCODE_MULTILINE) < 0) {
+ tor_free(cert_data);
log_warn(LD_REND, "Unable to encode legacy crosscert.");
goto err;
}
+ tor_free(cert_data);
/* Convert the encryption key to a string. */
if (crypto_pk_write_public_key_to_string(ip->enc_key.legacy, &key_str,
&key_str_len) < 0) {