summaryrefslogtreecommitdiff
path: root/src/or/router.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2018-04-24 08:51:58 -0400
committerNick Mathewson <nickm@torproject.org>2018-04-24 08:51:58 -0400
commit9be7608fda470713c4b9cd39a55f482706311717 (patch)
tree851cee5d5a6e436cb0f2e46e016e53bd972afcfe /src/or/router.c
parent192c7c8bf9a3c53d32e83557ebc62cf7cfa3b1ca (diff)
parent6182f60f758f85a214a7e84d76f6fddb2bffd730 (diff)
downloadtor-9be7608fda470713c4b9cd39a55f482706311717.tar.gz
tor-9be7608fda470713c4b9cd39a55f482706311717.zip
Merge branch 'maint-0.3.3'
Diffstat (limited to 'src/or/router.c')
-rw-r--r--src/or/router.c21
1 files changed, 14 insertions, 7 deletions
diff --git a/src/or/router.c b/src/or/router.c
index e5996f665e..ec49473cc2 100644
--- a/src/or/router.c
+++ b/src/or/router.c
@@ -138,7 +138,8 @@ get_onion_key(void)
}
/** Store a full copy of the current onion key into *<b>key</b>, and a full
- * copy of the most recent onion key into *<b>last</b>.
+ * copy of the most recent onion key into *<b>last</b>. Store NULL into
+ * a pointer if the corresponding key does not exist.
*/
void
dup_onion_keys(crypto_pk_t **key, crypto_pk_t **last)
@@ -146,8 +147,10 @@ dup_onion_keys(crypto_pk_t **key, crypto_pk_t **last)
tor_assert(key);
tor_assert(last);
tor_mutex_acquire(key_lock);
- tor_assert(onionkey);
- *key = crypto_pk_copy_full(onionkey);
+ if (onionkey)
+ *key = crypto_pk_copy_full(onionkey);
+ else
+ *last = NULL;
if (lastonionkey)
*last = crypto_pk_copy_full(lastonionkey);
else
@@ -214,10 +217,14 @@ construct_ntor_key_map(void)
{
di_digest256_map_t *m = NULL;
- dimap_add_entry(&m,
- curve25519_onion_key.pubkey.public_key,
- tor_memdup(&curve25519_onion_key,
- sizeof(curve25519_keypair_t)));
+ if (!tor_mem_is_zero((const char*)
+ curve25519_onion_key.pubkey.public_key,
+ CURVE25519_PUBKEY_LEN)) {
+ dimap_add_entry(&m,
+ curve25519_onion_key.pubkey.public_key,
+ tor_memdup(&curve25519_onion_key,
+ sizeof(curve25519_keypair_t)));
+ }
if (!tor_mem_is_zero((const char*)
last_curve25519_onion_key.pubkey.public_key,
CURVE25519_PUBKEY_LEN)) {