aboutsummaryrefslogtreecommitdiff
path: root/src/feature/rend
diff options
context:
space:
mode:
authorGeorge Kadianakis <desnacked@riseup.net>2019-04-08 16:18:44 +0300
committerGeorge Kadianakis <desnacked@riseup.net>2019-05-03 18:15:11 +0300
commitf5635989b06260710b282e75be7b731e2846f700 (patch)
tree62c67a6dfd0618a65470c1975d54a7c79217f9c5 /src/feature/rend
parent18d61c0e6e71dace189384c8af7f4fec158969b3 (diff)
downloadtor-f5635989b06260710b282e75be7b731e2846f700.tar.gz
tor-f5635989b06260710b282e75be7b731e2846f700.zip
Hiding crypt_path_t: Create a constructor for crypt_path_t.
We are using an opaque pointer so the structure needs to be allocated on the heap. This means we now need a constructor for crypt_path_t. Also modify all places initializing a crypt_path_t to use the constructor.
Diffstat (limited to 'src/feature/rend')
-rw-r--r--src/feature/rend/rendclient.c5
-rw-r--r--src/feature/rend/rendservice.c3
2 files changed, 3 insertions, 5 deletions
diff --git a/src/feature/rend/rendclient.c b/src/feature/rend/rendclient.c
index f84d221b1a..c6e9dde878 100644
--- a/src/feature/rend/rendclient.c
+++ b/src/feature/rend/rendclient.c
@@ -16,6 +16,7 @@
#include "core/or/circuituse.h"
#include "core/or/connection_edge.h"
#include "core/or/relay.h"
+#include "core/or/crypt_path.h"
#include "feature/client/circpathbias.h"
#include "feature/control/control_events.h"
#include "feature/dirclient/dirclient.h"
@@ -194,9 +195,7 @@ rend_client_send_introduction(origin_circuit_t *introcirc,
/* Initialize the pending_final_cpath and start the DH handshake. */
cpath = rendcirc->build_state->pending_final_cpath;
if (!cpath) {
- cpath = rendcirc->build_state->pending_final_cpath =
- tor_malloc_zero(sizeof(crypt_path_t));
- cpath->magic = CRYPT_PATH_MAGIC;
+ cpath = rendcirc->build_state->pending_final_cpath = crypt_path_new();
if (!(cpath->rend_dh_handshake_state = crypto_dh_new(DH_TYPE_REND))) {
log_warn(LD_BUG, "Internal error: couldn't allocate DH.");
status = -2;
diff --git a/src/feature/rend/rendservice.c b/src/feature/rend/rendservice.c
index 5c267f8e34..38da4cfe7a 100644
--- a/src/feature/rend/rendservice.c
+++ b/src/feature/rend/rendservice.c
@@ -2158,8 +2158,7 @@ rend_service_receive_introduction(origin_circuit_t *circuit,
launched->build_state->service_pending_final_cpath_ref->refcount = 1;
launched->build_state->service_pending_final_cpath_ref->cpath = cpath =
- tor_malloc_zero(sizeof(crypt_path_t));
- cpath->magic = CRYPT_PATH_MAGIC;
+ crypt_path_new();
launched->build_state->expiry_time = now + MAX_REND_TIMEOUT;
cpath->rend_dh_handshake_state = dh;