commit b8ceab9bb33a8096f14a671399ce34db439f63e2
Author: David Goulet <dgou...@torproject.org>
Date:   Sun Jul 23 10:43:16 2017 -0400

    prop224: Helper to dup a link_specifier_t object
    
    Signed-off-by: David Goulet <dgou...@torproject.org>
---
 src/or/hs_common.c | 18 ++++++++++++++++++
 src/or/hs_common.h |  5 +++++
 2 files changed, 23 insertions(+)

diff --git a/src/or/hs_common.c b/src/or/hs_common.c
index 27330bfcd..f6adad30c 100644
--- a/src/or/hs_common.c
+++ b/src/or/hs_common.c
@@ -541,6 +541,24 @@ 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 *dup = link_specifier_new();
+  memcpy(dup, lspec, sizeof(*dup));
+  /* The unrecognized field is a dynamic array so make sure to copy its
+   * content and not the pointer. */
+  link_specifier_setlen_un_unrecognized(
+                        dup, link_specifier_getlen_un_unrecognized(lspec));
+  if (link_specifier_getlen_un_unrecognized(dup)) {
+    memcpy(link_specifier_getarray_un_unrecognized(dup),
+           link_specifier_getconstarray_un_unrecognized(lspec),
+           link_specifier_getlen_un_unrecognized(dup));
+  }
+  return dup;
+}
+
 /* Initialize the entire HS subsytem. This is called in tor_init() before any
  * torrc options are loaded. Only for >= v3. */
 void
diff --git a/src/or/hs_common.h b/src/or/hs_common.h
index 203a5d081..a6c9994ef 100644
--- a/src/or/hs_common.h
+++ b/src/or/hs_common.h
@@ -11,6 +11,9 @@
 
 #include "or.h"
 
+/* Trunnel */
+#include "ed25519_cert.h"
+
 /* Protocol version 2. Use this instead of hardcoding "2" in the code base,
  * this adds a clearer semantic to the value when used. */
 #define HS_VERSION_TWO 2
@@ -113,6 +116,8 @@ const uint8_t *rend_data_get_pk_digest(const rend_data_t 
*rend_data,
 
 uint64_t hs_get_next_time_period_num(time_t now);
 
+link_specifier_t *hs_link_specifier_dup(const link_specifier_t *lspec);
+
 #ifdef HS_COMMON_PRIVATE
 
 #ifdef TOR_UNIT_TESTS



_______________________________________________
tor-commits mailing list
tor-commits@lists.torproject.org
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits

Reply via email to