]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
OpenSSL: Fix memory leak in crypto_ecdh_init()
authorJouni Malinen <jouni@codeaurora.org>
Wed, 8 May 2019 09:16:03 +0000 (12:16 +0300)
committerJouni Malinen <j@w1.fi>
Wed, 8 May 2019 09:16:03 +0000 (12:16 +0300)
ec_params needs to be freed before returning from the function.
Extension of this function to support BoringSSL introduced this memory
leak and that was later extended to be the only variant and apply to
OpenSSL and LibreSSL cases as well in commit c23e87d0d12d ("OpenSSL:
Replace EVP_PKEY_paramgen() with EC_KEY_new_by_curve_name()").

Fixes: f29761297b84 ("BoringSSL: Implement crypto_ecdh_init()")
Signed-off-by: Jouni Malinen <jouni@codeaurora.org>
src/crypto/crypto_openssl.c

index 228aa4bfa8d0339bf9f24659b9a08a0bbda4cde6..633199099e68ce048e374183aec27c5037ad1b48 100644 (file)
@@ -1880,7 +1880,7 @@ struct crypto_ecdh * crypto_ecdh_init(int group)
 {
        struct crypto_ecdh *ecdh;
        EVP_PKEY *params = NULL;
-       EC_KEY *ec_params;
+       EC_KEY *ec_params = NULL;
        EVP_PKEY_CTX *kctx = NULL;
 
        ecdh = os_zalloc(sizeof(*ecdh));
@@ -1923,6 +1923,7 @@ struct crypto_ecdh * crypto_ecdh_init(int group)
        }
 
 done:
+       EC_KEY_free(ec_params);
        EVP_PKEY_free(params);
        EVP_PKEY_CTX_free(kctx);