aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDavid Goulet <dgoulet@torproject.org>2023-01-11 09:03:29 -0500
committerDavid Goulet <dgoulet@torproject.org>2023-01-11 09:03:29 -0500
commitb9c7825f0ebe4bf5f8afc12b97cd8482dc706064 (patch)
treeb93722c0191b83d9d184ed31db7fea9f5841764c /src
parent482cde5931b537d49dc2535bf7a7771d740f441a (diff)
parent85547a9b5be5894672411b1ca3f5ad5619aa9478 (diff)
downloadtor-b9c7825f0ebe4bf5f8afc12b97cd8482dc706064.tar.gz
tor-b9c7825f0ebe4bf5f8afc12b97cd8482dc706064.zip
Merge branch 'maint-0.4.5' into maint-0.4.7
Diffstat (limited to 'src')
-rw-r--r--src/core/or/connection_or.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/src/core/or/connection_or.c b/src/core/or/connection_or.c
index 0534061e44..dd93628654 100644
--- a/src/core/or/connection_or.c
+++ b/src/core/or/connection_or.c
@@ -179,13 +179,18 @@ connection_or_set_identity_digest(or_connection_t *conn,
const int rsa_id_was_set = ! tor_digest_is_zero(conn->identity_digest);
const int ed_id_was_set =
chan && !ed25519_public_key_is_zero(&chan->ed25519_identity);
+ const int new_ed_id_is_set =
+ (ed_id && !ed25519_public_key_is_zero(ed_id));
const int rsa_changed =
tor_memneq(conn->identity_digest, rsa_digest, DIGEST_LEN);
- const int ed_changed = ed_id_was_set &&
- (!ed_id || !ed25519_pubkey_eq(ed_id, &chan->ed25519_identity));
+ const int ed_changed = bool_neq(ed_id_was_set, new_ed_id_is_set) ||
+ (ed_id_was_set && new_ed_id_is_set && chan &&
+ !ed25519_pubkey_eq(ed_id, &chan->ed25519_identity));
- tor_assert(!rsa_changed || !rsa_id_was_set);
- tor_assert(!ed_changed || !ed_id_was_set);
+ if (BUG(rsa_changed && rsa_id_was_set))
+ return;
+ if (BUG(ed_changed && ed_id_was_set))
+ return;
if (!rsa_changed && !ed_changed)
return;
@@ -200,8 +205,7 @@ connection_or_set_identity_digest(or_connection_t *conn,
memcpy(conn->identity_digest, rsa_digest, DIGEST_LEN);
/* If we're initializing the IDs to zero, don't add a mapping yet. */
- if (tor_digest_is_zero(rsa_digest) &&
- (!ed_id || ed25519_public_key_is_zero(ed_id)))
+ if (tor_digest_is_zero(rsa_digest) && !new_ed_id_is_set)
return;
/* Deal with channels */