aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJouni Malinen <jouni@codeaurora.org>2019-05-08 15:55:57 (GMT)
committerJouni Malinen <j@w1.fi>2019-05-08 15:55:57 (GMT)
commit677e120181d361a2b52e1f04e1fa5084d9a21873 (patch)
tree0f9a661f2034c21b368ae0c253abf90e05b709b9
parent8925d2010d93ff6bc7119f6efc284384ec23efd4 (diff)
downloadhostap-677e120181d361a2b52e1f04e1fa5084d9a21873.zip
hostap-677e120181d361a2b52e1f04e1fa5084d9a21873.tar.gz
hostap-677e120181d361a2b52e1f04e1fa5084d9a21873.tar.bz2
dragonfly: Fix a memory leak on error path
This is mostly a theoretical case, but since crypto_bignum_rand() could fail, need to free the allocated struct crypto_bignum *tmp in such a case. Signed-off-by: Jouni Malinen <jouni@codeaurora.org>
-rw-r--r--src/common/dragonfly.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/common/dragonfly.c b/src/common/dragonfly.c
index 10d968a..e98bce6 100644
--- a/src/common/dragonfly.c
+++ b/src/common/dragonfly.c
@@ -40,8 +40,10 @@ int dragonfly_get_random_qr_qnr(const struct crypto_bignum *prime,
int res;
tmp = crypto_bignum_init();
- if (!tmp || crypto_bignum_rand(tmp, prime) < 0)
+ if (!tmp || crypto_bignum_rand(tmp, prime) < 0) {
+ crypto_bignum_deinit(tmp, 0);
break;
+ }
res = crypto_bignum_legendre(tmp, prime);
if (res == 1 && !(*qr))