aboutsummaryrefslogtreecommitdiff
path: root/src/core/or/crypt_path.c
diff options
context:
space:
mode:
authorGeorge Kadianakis <desnacked@riseup.net>2019-04-10 16:28:29 +0300
committerGeorge Kadianakis <desnacked@riseup.net>2019-05-03 18:15:11 +0300
commitcd38e41620120a11a70ebe059f3adbaa05e4c1ff (patch)
treec6418400b0f87bbcc52a48611633b7f61b28a846 /src/core/or/crypt_path.c
parentf5635989b06260710b282e75be7b731e2846f700 (diff)
downloadtor-cd38e41620120a11a70ebe059f3adbaa05e4c1ff.tar.gz
tor-cd38e41620120a11a70ebe059f3adbaa05e4c1ff.zip
Hiding crypt_path_t: Ensure that ->private is initialized.
Now that we are using a constructor we should be more careful that we are always using the constructor to initialize crypt_path_t, so make sure that ->private is initialized.
Diffstat (limited to 'src/core/or/crypt_path.c')
-rw-r--r--src/core/or/crypt_path.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/core/or/crypt_path.c b/src/core/or/crypt_path.c
index 975af6c16d..e24712ed89 100644
--- a/src/core/or/crypt_path.c
+++ b/src/core/or/crypt_path.c
@@ -108,6 +108,7 @@ assert_cpath_layer_ok(const crypt_path_t *cp)
// tor_assert(cp->port);
tor_assert(cp);
tor_assert(cp->magic == CRYPT_PATH_MAGIC);
+ tor_assert(cp->private);
switch (cp->state)
{
case CPATH_STATE_OPEN:
@@ -152,6 +153,7 @@ circuit_init_cpath_crypto(crypt_path_t *cpath,
{
tor_assert(cpath);
+ tor_assert(cpath->private);
return relay_crypto_init(&cpath->private->crypto, key_data, key_data_len, reverse,
is_hs_v3);
}
@@ -161,7 +163,7 @@ circuit_init_cpath_crypto(crypt_path_t *cpath,
void
circuit_free_cpath_node(crypt_path_t *victim)
{
- if (!victim)
+ if (!victim || BUG(!victim->private))
return;
relay_crypto_clear(&victim->private->crypto);
@@ -181,6 +183,9 @@ circuit_free_cpath_node(crypt_path_t *victim)
void
cpath_crypt_cell(const crypt_path_t *cpath, uint8_t *payload, bool is_decrypt)
{
+ tor_assert(cpath);
+ tor_assert(cpath->private);
+
if (is_decrypt) {
relay_crypt_one_payload(cpath->private->crypto.b_crypto, payload);
} else {
@@ -192,6 +197,8 @@ cpath_crypt_cell(const crypt_path_t *cpath, uint8_t *payload, bool is_decrypt)
struct crypto_digest_t *
cpath_get_incoming_digest(const crypt_path_t *cpath)
{
+ tor_assert(cpath);
+ tor_assert(cpath->private);
return cpath->private->crypto.b_digest;
}
@@ -200,5 +207,7 @@ cpath_get_incoming_digest(const crypt_path_t *cpath)
void
cpath_set_cell_forward_digest(crypt_path_t *cpath, cell_t *cell)
{
+ tor_assert(cpath);
+ tor_assert(cpath->private);
relay_set_digest(cpath->private->crypto.f_digest, cell);
}