[tor-commits] [tor/maint-0.3.4] Fix memory leak in pick_hsdir_v3().

nickm at torproject.org nickm at torproject.org
Fri Jun 29 17:07:19 UTC 2018


commit ce5d055ed7e4d8e5d1c0b0b922738c87b6a8da1c
Author: Alexander Færøy <ahf at torproject.org>
Date:   Sat Jun 23 03:40:32 2018 +0200

    Fix memory leak in pick_hsdir_v3().
    
    This patch fixes a memory leak in pick_hsdir_v3() where we might return
    early, but forgot to free the responsible_hsdirs variable. We solve this
    by not allocating storage for responsible_hsdirs until it's actually
    needed.
    
    See: Coverity CID 1437449
---
 src/or/hs_client.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/or/hs_client.c b/src/or/hs_client.c
index 551cf5055..4e2824c13 100644
--- a/src/or/hs_client.c
+++ b/src/or/hs_client.c
@@ -365,14 +365,12 @@ pick_hsdir_v3(const ed25519_public_key_t *onion_identity_pk)
   int retval;
   char base64_blinded_pubkey[ED25519_BASE64_LEN + 1];
   uint64_t current_time_period = hs_get_time_period_num(0);
-  smartlist_t *responsible_hsdirs;
+  smartlist_t *responsible_hsdirs = NULL;
   ed25519_public_key_t blinded_pubkey;
   routerstatus_t *hsdir_rs = NULL;
 
   tor_assert(onion_identity_pk);
 
-  responsible_hsdirs = smartlist_new();
-
   /* Get blinded pubkey of hidden service */
   hs_build_blinded_pubkey(onion_identity_pk, NULL, 0,
                           current_time_period, &blinded_pubkey);
@@ -383,6 +381,8 @@ pick_hsdir_v3(const ed25519_public_key_t *onion_identity_pk)
   }
 
   /* Get responsible hsdirs of service for this time period */
+  responsible_hsdirs = smartlist_new();
+
   hs_get_responsible_hsdirs(&blinded_pubkey, current_time_period,
                             0, 1, responsible_hsdirs);
 





More information about the tor-commits mailing list