[tor-commits] [tor/master] hs: Do not assert on rend_data while iterating over circuits

nickm at torproject.org nickm at torproject.org
Fri Sep 8 13:02:13 UTC 2017


commit fa87aa00c4096d44b71a3340f933fa4f8f23334c
Author: David Goulet <dgoulet at torproject.org>
Date:   Thu Sep 7 14:24:49 2017 -0400

    hs: Do not assert on rend_data while iterating over circuits
    
    The pruning process and the deleting ephemeral service function iterates over
    all circuits and were asserting on rend_data for a matching circuit. This is
    not good because now we have v3 circuits without a rend_data.
    
    Fixes #23429
    
    Signed-off-by: David Goulet <dgoulet at torproject.org>
---
 src/or/rendservice.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/src/or/rendservice.c b/src/or/rendservice.c
index 9edb7cc4b..0017444b9 100644
--- a/src/or/rendservice.c
+++ b/src/or/rendservice.c
@@ -558,7 +558,10 @@ rend_service_prune_list_impl_(void)
    * matching surviving configured service. If not, close the circuit. */
   while ((ocirc = circuit_get_next_service_intro_circ(ocirc))) {
     int keep_it = 0;
-    tor_assert(ocirc->rend_data);
+    if (ocirc->rend_data == NULL) {
+      /* This is a v3 circuit, ignore it. */
+      continue;
+    }
     SMARTLIST_FOREACH_BEGIN(surviving_services, const rend_service_t *, s) {
       if (rend_circuit_pk_digest_eq(ocirc, (uint8_t *) s->pk_digest)) {
         /* Keep this circuit as we have a matching configured service. */
@@ -915,8 +918,8 @@ rend_service_del_ephemeral(const char *service_id)
         (circ->purpose == CIRCUIT_PURPOSE_S_ESTABLISH_INTRO ||
          circ->purpose == CIRCUIT_PURPOSE_S_INTRO)) {
       origin_circuit_t *oc = TO_ORIGIN_CIRCUIT(circ);
-      tor_assert(oc->rend_data);
-      if (!rend_circuit_pk_digest_eq(oc, (uint8_t *) s->pk_digest)) {
+      if (oc->rend_data == NULL ||
+          !rend_circuit_pk_digest_eq(oc, (uint8_t *) s->pk_digest)) {
         continue;
       }
       log_debug(LD_REND, "Closing intro point %s for service %s.",
@@ -4260,7 +4263,6 @@ rend_service_set_connection_addr_port(edge_connection_t *conn,
   tor_assert(circ->base_.purpose == CIRCUIT_PURPOSE_S_REND_JOINED);
   tor_assert(circ->rend_data);
   log_debug(LD_REND,"beginning to hunt for addr/port");
-  /* XXX: This is version 2 specific (only one supported). */
   rend_pk_digest = (char *) rend_data_get_pk_digest(circ->rend_data, NULL);
   base32_encode(serviceid, REND_SERVICE_ID_LEN_BASE32+1,
                 rend_pk_digest, REND_SERVICE_ID_LEN);





More information about the tor-commits mailing list