Browse Source

Fix a bunch of leaks in hs_cache/upload_and_download_hs_desc

Nick Mathewson 7 years ago
parent
commit
29ae8dcf96
2 changed files with 7 additions and 0 deletions
  1. 2 0
      src/or/hs_descriptor.c
  2. 5 0
      src/test/test_hs_cache.c

+ 2 - 0
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);

+ 5 - 0
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