aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJouni Malinen <jouni@codeaurora.org>2019-05-08 15:53:32 (GMT)
committerJouni Malinen <j@w1.fi>2019-05-08 15:53:32 (GMT)
commit8925d2010d93ff6bc7119f6efc284384ec23efd4 (patch)
tree1eb7995d7bca0a1e9cc336789998720118c807ef
parent57ec74ea9b9afb7d0f841cbd70955152251b4813 (diff)
downloadhostap-8925d2010d93ff6bc7119f6efc284384ec23efd4.zip
hostap-8925d2010d93ff6bc7119f6efc284384ec23efd4.tar.gz
hostap-8925d2010d93ff6bc7119f6efc284384ec23efd4.tar.bz2
OpenSSL: Fix memory leak in crypto_dh_derive_secret()
BN_clear() does not free the BIGNUM; it only clears its value. Fix this memory leak by using the appropriate BN_clear_free() function instead. Fixes: b11fa98bcb8a ("Add explicit checks for peer's DH public key") Signed-off-by: Jouni Malinen <jouni@codeaurora.org>
-rw-r--r--src/crypto/crypto_openssl.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/crypto/crypto_openssl.c b/src/crypto/crypto_openssl.c
index 6331990..fb278c2 100644
--- a/src/crypto/crypto_openssl.c
+++ b/src/crypto/crypto_openssl.c
@@ -570,8 +570,8 @@ int crypto_dh_derive_secret(u8 generator, const u8 *prime, size_t prime_len,
failed = !q || !ctx || !tmp ||
!BN_mod_exp(tmp, pub, q, p, ctx) ||
!BN_is_one(tmp);
- BN_clear(q);
- BN_clear(tmp);
+ BN_clear_free(q);
+ BN_clear_free(tmp);
BN_CTX_free(ctx);
if (failed)
goto fail;
@@ -580,8 +580,8 @@ int crypto_dh_derive_secret(u8 generator, const u8 *prime, size_t prime_len,
res = crypto_mod_exp(pubkey, pubkey_len, privkey, privkey_len,
prime, prime_len, secret, len);
fail:
- BN_clear(pub);
- BN_clear(p);
+ BN_clear_free(pub);
+ BN_clear_free(p);
return res;
}