]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Avoid a crash if our "current" and "old" ntor onion keys are equal
authorNick Mathewson <nickm@torproject.org>
Wed, 18 Sep 2019 15:14:45 +0000 (11:14 -0400)
committerNick Mathewson <nickm@torproject.org>
Wed, 18 Sep 2019 15:14:45 +0000 (11:14 -0400)
Our dimap code asserts if you try to add the same key twice; this
can't happen if everything is running smoothly, but it's possible if
you try to start a relay where secret_onion_key_ntor is the same as
secret_onion_key_ntor.old.

Fixes bug 30916; bugfix on 0.2.4.8-alpha when ntor keys were
introduced.

changes/bug30916 [new file with mode: 0644]
src/feature/relay/router.c

diff --git a/changes/bug30916 b/changes/bug30916
new file mode 100644 (file)
index 0000000..b006bfc
--- /dev/null
@@ -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.
index 88a30cef0861e65a9e4891dca3a6fd5fdf177009..1dbaf2ed66c58aa95224d360f269a75b2fbdc97c 100644 (file)
@@ -286,7 +286,8 @@ construct_ntor_key_map(void)
                     tor_memdup(&curve25519_onion_key,
                                sizeof(curve25519_keypair_t)));
   }
-  if (!tor_mem_is_zero((const char*)last_pk, CURVE25519_PUBKEY_LEN)) {
+  if (!tor_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)));