[tor-commits] [tor/master] hs: abolish hs_desc_link_specifier_dup()

nickm at torproject.org nickm at torproject.org
Tue Mar 12 15:10:06 UTC 2019


commit 680b2afd84a318e11f79526bfedff29870307ed0
Author: teor <teor at torproject.org>
Date:   Fri Mar 8 16:47:20 2019 +1000

    hs: abolish hs_desc_link_specifier_dup()
    
    The previous commits introduced link_specifier_dup(), which is
    implemented using trunnel's opaque interfaces. So we can now
    remove hs_desc_link_specifier_dup().
    
    Cleanup after bug 22781.
---
 src/feature/hs/hs_cell.c         |  2 +-
 src/feature/hs/hs_common.c       | 18 ------------------
 src/feature/hs/hs_common.h       |  2 --
 src/trunnel/ed25519_cert.trunnel |  6 ------
 4 files changed, 1 insertion(+), 27 deletions(-)

diff --git a/src/feature/hs/hs_cell.c b/src/feature/hs/hs_cell.c
index e24520da4..1dae9c79c 100644
--- a/src/feature/hs/hs_cell.c
+++ b/src/feature/hs/hs_cell.c
@@ -759,7 +759,7 @@ hs_cell_parse_introduce2(hs_cell_introduce2_data_t *data,
     if (BUG(!lspec)) {
       goto done;
     }
-    link_specifier_t *lspec_dup = hs_link_specifier_dup(lspec);
+    link_specifier_t *lspec_dup = link_specifier_dup(lspec);
     if (BUG(!lspec_dup)) {
       goto done;
     }
diff --git a/src/feature/hs/hs_common.c b/src/feature/hs/hs_common.c
index a1dc0a629..2cc23a418 100644
--- a/src/feature/hs/hs_common.c
+++ b/src/feature/hs/hs_common.c
@@ -1009,24 +1009,6 @@ hs_build_address(const ed25519_public_key_t *key, uint8_t version,
   tor_assert(hs_address_is_valid(addr_out));
 }
 
-/* Return a newly allocated copy of lspec. */
-link_specifier_t *
-hs_link_specifier_dup(const link_specifier_t *lspec)
-{
-  link_specifier_t *result = link_specifier_new();
-  memcpy(result, lspec, sizeof(*result));
-  /* The unrecognized field is a dynamic array so make sure to copy its
-   * content and not the pointer. */
-  link_specifier_setlen_un_unrecognized(
-                  result, link_specifier_getlen_un_unrecognized(lspec));
-  if (link_specifier_getlen_un_unrecognized(result)) {
-    memcpy(link_specifier_getarray_un_unrecognized(result),
-           link_specifier_getconstarray_un_unrecognized(lspec),
-           link_specifier_getlen_un_unrecognized(result));
-  }
-  return result;
-}
-
 /* From a given ed25519 public key pk and an optional secret, compute a
  * blinded public key and put it in blinded_pk_out. This is only useful to
  * the client side because the client only has access to the identity public
diff --git a/src/feature/hs/hs_common.h b/src/feature/hs/hs_common.h
index 544e63e59..abf39fa43 100644
--- a/src/feature/hs/hs_common.h
+++ b/src/feature/hs/hs_common.h
@@ -217,8 +217,6 @@ uint64_t hs_get_time_period_num(time_t now);
 uint64_t hs_get_next_time_period_num(time_t now);
 time_t hs_get_start_time_of_next_time_period(time_t now);
 
-link_specifier_t *hs_link_specifier_dup(const link_specifier_t *lspec);
-
 MOCK_DECL(int, hs_in_period_between_tp_and_srv,
           (const networkstatus_t *consensus, time_t now));
 
diff --git a/src/trunnel/ed25519_cert.trunnel b/src/trunnel/ed25519_cert.trunnel
index 8d6483d55..e424ce546 100644
--- a/src/trunnel/ed25519_cert.trunnel
+++ b/src/trunnel/ed25519_cert.trunnel
@@ -28,12 +28,6 @@ const LS_IPV6 = 0x01;
 const LS_LEGACY_ID = 0x02;
 const LS_ED25519_ID = 0x03;
 
-// XXX hs_link_specifier_dup() violates the opaqueness of link_specifier_t by
-//  taking its sizeof(). If we ever want to turn on TRUNNEL_OPAQUE, or
-//  if we ever make link_specifier contain other types, we will
-//  need to refactor that function to do the copy by encoding and decoding the
-//  object.
-
 // amended from tor.trunnel
 struct link_specifier {
   u8 ls_type;





More information about the tor-commits mailing list