[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [tor/master] Hiding crypt_path_t: Ensure that ->private is initialized.



commit cd38e41620120a11a70ebe059f3adbaa05e4c1ff
Author: George Kadianakis <desnacked@xxxxxxxxxx>
Date:   Wed Apr 10 16:28:29 2019 +0300

    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.
---
 src/core/or/crypt_path.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/src/core/or/crypt_path.c b/src/core/or/crypt_path.c
index 975af6c16..e24712ed8 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);
 }



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