diff options
author | teor <teor@torproject.org> | 2018-08-23 19:21:26 +1000 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2019-03-12 11:09:53 -0400 |
commit | bb98bc8562c59c0357e8911fa8952ed5ee20206d (patch) | |
tree | 9c89599717f4bdb3c4bfc7697763f36b8a9dcaad /src/feature/hs/hs_common.c | |
parent | 6170d3fcf12f4345ec13561d0f444930f2f12e84 (diff) | |
download | tor-bb98bc8562c59c0357e8911fa8952ed5ee20206d.tar.gz tor-bb98bc8562c59c0357e8911fa8952ed5ee20206d.zip |
hs: abolish hs_desc_link_specifier_t
The previous commits for 23576 confused hs_desc_link_specifier_t
and link_specifier_t. Removing hs_desc_link_specifier_t fixes this
confusion.
Fixes bug 22781; bugfix on 0.3.2.1-alpha.
Diffstat (limited to 'src/feature/hs/hs_common.c')
-rw-r--r-- | src/feature/hs/hs_common.c | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/src/feature/hs/hs_common.c b/src/feature/hs/hs_common.c index 5d8f54230f..a1dc0a6290 100644 --- a/src/feature/hs/hs_common.c +++ b/src/feature/hs/hs_common.c @@ -1843,3 +1843,42 @@ hs_inc_rdv_stream_counter(origin_circuit_t *circ) tor_assert_nonfatal_unreached(); } } + +/* Return a newly allocated link specifier object that is a copy of dst. */ +link_specifier_t * +link_specifier_dup(const link_specifier_t *src) +{ + link_specifier_t *dup = NULL; + uint8_t *buf = NULL; + + if (BUG(!src)) { + goto err; + } + + ssize_t encoded_len_alloc = link_specifier_encoded_len(src); + if (BUG(encoded_len_alloc < 0)) { + goto err; + } + + buf = tor_malloc_zero(encoded_len_alloc); + ssize_t encoded_len_data = link_specifier_encode(buf, + encoded_len_alloc, + src); + if (BUG(encoded_len_data < 0)) { + goto err; + } + + ssize_t parsed_len = link_specifier_parse(&dup, buf, encoded_len_alloc); + if (BUG(parsed_len < 0)) { + goto err; + } + + goto done; + + err: + dup = NULL; + + done: + tor_free(buf); + return dup; +} |