[tor-commits] [tor/master] relay: Refactor some long lines from circuit_extend()

nickm at torproject.org nickm at torproject.org
Thu Apr 9 15:56:22 UTC 2020


commit 2640030b10038ed0e6fc4a4a9628745708be9d83
Author: teor <teor at torproject.org>
Date:   Wed Mar 18 18:48:01 2020 +1000

    relay: Refactor some long lines from circuit_extend()
    
    Part of 33633.
---
 src/feature/relay/circuitbuild_relay.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/src/feature/relay/circuitbuild_relay.c b/src/feature/relay/circuitbuild_relay.c
index 2781d1400..c57f0e5e8 100644
--- a/src/feature/relay/circuitbuild_relay.c
+++ b/src/feature/relay/circuitbuild_relay.c
@@ -133,12 +133,12 @@ circuit_extend_lspec_valid_helper(const extend_cell_t *ec,
     return -1;
   }
 
+  const channel_t *p_chan = CONST_TO_OR_CIRCUIT(circ)->p_chan;
+
   /* Next, check if we're being asked to connect to the hop that the
    * extend cell came from. There isn't any reason for that, and it can
    * assist circular-path attacks. */
-  if (tor_memeq(ec->node_id,
-                CONST_TO_OR_CIRCUIT(circ)->p_chan->identity_digest,
-                DIGEST_LEN)) {
+  if (tor_memeq(ec->node_id, p_chan->identity_digest, DIGEST_LEN)) {
     log_fn(LOG_PROTOCOL_WARN, LD_PROTOCOL,
            "Client asked me to extend back to the previous hop.");
     return -1;
@@ -146,8 +146,7 @@ circuit_extend_lspec_valid_helper(const extend_cell_t *ec,
 
   /* Check the previous hop Ed25519 ID too */
   if (! ed25519_public_key_is_zero(&ec->ed_pubkey) &&
-      ed25519_pubkey_eq(&ec->ed_pubkey,
-                      &CONST_TO_OR_CIRCUIT(circ)->p_chan->ed25519_identity)) {
+      ed25519_pubkey_eq(&ec->ed_pubkey, &p_chan->ed25519_identity)) {
     log_fn(LOG_PROTOCOL_WARN, LD_PROTOCOL,
            "Client asked me to extend back to the previous hop "
            "(by Ed25519 ID).");





More information about the tor-commits mailing list