[tor-commits] [tor/master] Fix a bunch of leaks in hs_cache/upload_and_download_hs_desc

nickm at torproject.org nickm at torproject.org
Fri Nov 4 18:48:12 UTC 2016


commit 29ae8dcf96532eb5be8023a29de404576d5d2339
Author: Nick Mathewson <nickm at torproject.org>
Date:   Fri Nov 4 14:13:30 2016 -0400

    Fix a bunch of leaks in hs_cache/upload_and_download_hs_desc
---
 src/or/hs_descriptor.c   | 2 ++
 src/test/test_hs_cache.c | 5 +++++
 2 files changed, 7 insertions(+)

diff --git a/src/or/hs_descriptor.c b/src/or/hs_descriptor.c
index 0676c71..3986e8d 100644
--- a/src/or/hs_descriptor.c
+++ b/src/or/hs_descriptor.c
@@ -324,8 +324,10 @@ encode_enc_key(const ed25519_keypair_t *sig_key,
       goto err;
     }
     if (encode_cert(cross_cert, &encoded_cert)) {
+      tor_cert_free(cross_cert);
       goto err;
     }
+    tor_cert_free(cross_cert);
     if (curve25519_public_to_base64(key_fp_b64,
                                     &ip->enc_key.curve25519.pubkey) < 0) {
       tor_free(encoded_cert);
diff --git a/src/test/test_hs_cache.c b/src/test/test_hs_cache.c
index dc7cf03..e05e1f2 100644
--- a/src/test/test_hs_cache.c
+++ b/src/test/test_hs_cache.c
@@ -6,6 +6,7 @@
  * \brief Test hidden service caches.
  */
 
+#define CONNECTION_PRIVATE
 #define HS_CACHE_PRIVATE
 
 #include "ed25519_cert.h"
@@ -322,10 +323,13 @@ helper_fetch_desc_from_hsdir(const ed25519_public_key_t *blinded_key)
 
     fetch_from_buf_http(TO_CONN(conn)->outbuf, &headers, MAX_HEADERS_SIZE,
                         &received_desc, &body_used, 10000, 0);
+    tor_free(headers);
   }
 
  done:
   tor_free(hsdir_query_str);
+  if (conn)
+    connection_free_(TO_CONN(conn));
 
   return received_desc;
 }
@@ -373,6 +377,7 @@ test_upload_and_download_hs_desc(void *arg)
  done:
   tor_free(received_desc_str);
   tor_free(published_desc_str);
+  hs_descriptor_free(published_desc);
 }
 
 /* Test that HSDirs reject outdated descriptors based on their revision





More information about the tor-commits mailing list