From edd6d5884aaab2121f7a2ef9ffd3ff7bf9f50c2d Mon Sep 17 00:00:00 2001 From: Mark Andrews Date: Fri, 5 Feb 2021 17:08:33 +1100 Subject: [PATCH] Free OpenSSL keys in ./configure Failure to free OpenSSL keys in ./configure results in ASAN errors and false negative errors. --- configure | 12 ++++++++++-- configure.ac | 12 ++++++++++-- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/configure b/configure index 4b6b1e11f3..f56d94deb0 100755 --- a/configure +++ b/configure @@ -17511,6 +17511,10 @@ int main() { ec384 = EC_KEY_new_by_curve_name(NID_secp384r1); if (ec256 == NULL || ec384 == NULL) return (2); + if (ec256 != NULL) + EC_KEY_free(ec256); + if (ec384 != NULL) + EC_KEY_free(ec384); return (0); } @@ -17657,8 +17661,10 @@ int main() { EVP_PKEY_CTX *ctx; ctx = EVP_PKEY_CTX_new_id(NID_ED25519, NULL); - if (ctx == NULL) + if (ctx == NULL) { return (2); + } + EVP_PKEY_CTX_free(ctx); return (0); } @@ -17715,8 +17721,10 @@ int main() { EVP_PKEY_CTX *ctx; ctx = EVP_PKEY_CTX_new_id(NID_ED448, NULL); - if (ctx == NULL) + if (ctx == NULL) { return (2); + } + EVP_PKEY_CTX_free(ctx); return (0); } diff --git a/configure.ac b/configure.ac index 6ecdbf9b34..2aa1ff87f7 100644 --- a/configure.ac +++ b/configure.ac @@ -1806,6 +1806,10 @@ int main() { ec384 = EC_KEY_new_by_curve_name(NID_secp384r1); if (ec256 == NULL || ec384 == NULL) return (2); + if (ec256 != NULL) + EC_KEY_free(ec256); + if (ec384 != NULL) + EC_KEY_free(ec384); return (0); } ], @@ -1918,8 +1922,10 @@ int main() { EVP_PKEY_CTX *ctx; ctx = EVP_PKEY_CTX_new_id(NID_ED25519, NULL); - if (ctx == NULL) + if (ctx == NULL) { return (2); + } + EVP_PKEY_CTX_free(ctx); return (0); } ], @@ -1959,8 +1965,10 @@ int main() { EVP_PKEY_CTX *ctx; ctx = EVP_PKEY_CTX_new_id(NID_ED448, NULL); - if (ctx == NULL) + if (ctx == NULL) { return (2); + } + EVP_PKEY_CTX_free(ctx); return (0); } ],