diff options
author | David Goulet <dgoulet@torproject.org> | 2017-07-23 10:43:16 -0400 |
---|---|---|
committer | David Goulet <dgoulet@torproject.org> | 2017-07-25 13:11:40 -0400 |
commit | b8ceab9bb33a8096f14a671399ce34db439f63e2 (patch) | |
tree | 197f17e510bdacbad12d065d946dff46553e500b /src/or/hs_common.c | |
parent | 2b9575a9c0ecf6e3880654be16d103326788cecf (diff) | |
download | tor-b8ceab9bb33a8096f14a671399ce34db439f63e2.tar.gz tor-b8ceab9bb33a8096f14a671399ce34db439f63e2.zip |
prop224: Helper to dup a link_specifier_t object
Signed-off-by: David Goulet <dgoulet@torproject.org>
Diffstat (limited to 'src/or/hs_common.c')
-rw-r--r-- | src/or/hs_common.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/or/hs_common.c b/src/or/hs_common.c index 27330bfcdb..f6adad30cc 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 |