diff options
author | George Kadianakis <desnacked@riseup.net> | 2019-09-25 14:18:15 +0300 |
---|---|---|
committer | George Kadianakis <desnacked@riseup.net> | 2019-09-25 14:18:15 +0300 |
commit | 0a77e5f1c23d43d25a10436dcd30adb4596762fb (patch) | |
tree | f8003152da7683857873759a699113ddd1e818fb | |
parent | 09769779a0b0d422b1cc4ec22ca8d95daba706ba (diff) | |
parent | 4bbefc2aac2d3770817200700e2a384d966bffe2 (diff) | |
download | tor-0a77e5f1c23d43d25a10436dcd30adb4596762fb.tar.gz tor-0a77e5f1c23d43d25a10436dcd30adb4596762fb.zip |
Merge branch 'tor-github/pr/1341'
-rw-r--r-- | changes/bug30916 | 4 | ||||
-rw-r--r-- | src/feature/relay/router.c | 18 |
2 files changed, 12 insertions, 10 deletions
diff --git a/changes/bug30916 b/changes/bug30916 new file mode 100644 index 0000000000..b006bfc75d --- /dev/null +++ b/changes/bug30916 @@ -0,0 +1,4 @@ + o Minor bugfixes (relay): + - Avoid crashing when starting with a corrupt keys directory where + the old ntor key and the new ntor key are identical. Fixes bug 30916; + bugfix on 0.2.4.8-alpha. diff --git a/src/feature/relay/router.c b/src/feature/relay/router.c index 51ced6289d..11b32bd8e7 100644 --- a/src/feature/relay/router.c +++ b/src/feature/relay/router.c @@ -284,19 +284,17 @@ construct_ntor_key_map(void) { di_digest256_map_t *m = NULL; - if (!fast_mem_is_zero((const char*) - curve25519_onion_key.pubkey.public_key, - CURVE25519_PUBKEY_LEN)) { - dimap_add_entry(&m, - curve25519_onion_key.pubkey.public_key, + const uint8_t *cur_pk = curve25519_onion_key.pubkey.public_key; + const uint8_t *last_pk = last_curve25519_onion_key.pubkey.public_key; + + if (!fast_mem_is_zero((const char *)cur_pk, CURVE25519_PUBKEY_LEN)) { + dimap_add_entry(&m, cur_pk, tor_memdup(&curve25519_onion_key, sizeof(curve25519_keypair_t))); } - if (!fast_mem_is_zero((const char*) - last_curve25519_onion_key.pubkey.public_key, - CURVE25519_PUBKEY_LEN)) { - dimap_add_entry(&m, - last_curve25519_onion_key.pubkey.public_key, + if (!fast_mem_is_zero((const char*)last_pk, CURVE25519_PUBKEY_LEN) && + tor_memneq(cur_pk, last_pk, CURVE25519_PUBKEY_LEN)) { + dimap_add_entry(&m, last_pk, tor_memdup(&last_curve25519_onion_key, sizeof(curve25519_keypair_t))); } |