]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Fix memory leak in crypto_pk_asn1_decode_private.
authorNick Mathewson <nickm@torproject.org>
Sat, 14 Mar 2020 18:17:33 +0000 (14:17 -0400)
committerNick Mathewson <nickm@torproject.org>
Sat, 14 Mar 2020 18:17:37 +0000 (14:17 -0400)
(Deep, deep thanks to Taylor for reminding me to test this!)

src/lib/crypt_ops/crypto_rsa_openssl.c

index 39b7aaf0cf04f7d395a4e1417f843a0e5e2d1706..0db25f3473118bd5f1d14110ef23ee61f54ab5eb 100644 (file)
@@ -590,6 +590,7 @@ crypto_pk_asn1_decode_private(const char *str, size_t len, int max_bits)
   if (max_bits >= 0 && rsa->n && BN_num_bits(rsa->n) > max_bits) {
 #endif
     log_info(LD_CRYPTO, "Private key longer than expected.");
+    RSA_free(rsa);
     return NULL;
   }
   crypto_pk_t *result = crypto_new_pk_from_openssl_rsa_(rsa);