From 452b4c03a60ba85ca3cc68b559ed10428983dad7 Mon Sep 17 00:00:00 2001 From: Tesfa Mael Date: Thu, 12 Mar 2020 23:24:44 -0700 Subject: [PATCH] Fix memory leak --- src/ssl.c | 7 +++++-- tests/api.c | 1 - 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/ssl.c b/src/ssl.c index 2352a7b6d..b39ccdd24 100644 --- a/src/ssl.c +++ b/src/ssl.c @@ -18298,7 +18298,7 @@ int wolfSSL_EVP_MD_type(const WOLFSSL_EVP_MD *md) if (enc == 0 || enc == 1) ctx->enc = enc ? 1 : 0; if (key) { - ret = wc_AesXtsSetKey(&ctx->cipher.xts, key, ctx->keyLen, + ret = wc_AesXtsSetKey(&ctx->cipher.xts, key, ctx->keyLen, ctx->enc ? AES_ENCRYPTION : AES_DECRYPTION, NULL, 0); if (ret != 0) { WOLFSSL_MSG("wc_AesXtsSetKey() failed"); @@ -18328,7 +18328,7 @@ int wolfSSL_EVP_MD_type(const WOLFSSL_EVP_MD *md) if (enc == 0 || enc == 1) ctx->enc = enc ? 1 : 0; if (key) { - ret = wc_AesXtsSetKey(&ctx->cipher.xts, key, ctx->keyLen, + ret = wc_AesXtsSetKey(&ctx->cipher.xts, key, ctx->keyLen, ctx->enc ? AES_ENCRYPTION : AES_DECRYPTION, NULL, 0); if (ret != 0) { WOLFSSL_MSG("wc_AesXtsSetKey() failed"); @@ -36137,6 +36137,7 @@ int wolfSSL_EC_POINT_get_affine_coordinates_GFp(const WOLFSSL_EC_GROUP *group, BN_copy(x, point->X); BN_copy(y, point->Y); + mp_clear(&modulus); return WOLFSSL_SUCCESS; } @@ -48640,8 +48641,10 @@ int wolfSSL_BN_clear_bit(WOLFSSL_BIGNUM* bn, int n) goto cleanup; } } + ret = WOLFSSL_SUCCESS; cleanup: + mp_clear(tmp); #ifdef WOLFSSL_SMALL_STACK if (tmp) XFREE(tmp, NULL, DYNAMIC_TYPE_BIGINT); diff --git a/tests/api.c b/tests/api.c index 58a5e4f7f..a6d862174 100644 --- a/tests/api.c +++ b/tests/api.c @@ -1839,7 +1839,6 @@ static void test_wolfSSL_EC(void) /* Force non-affine coordinates */ AssertIntEQ(wolfSSL_BN_add(new_point->Z, (WOLFSSL_BIGNUM*)BN_value_one(), (WOLFSSL_BIGNUM*)BN_value_one()), 1); - new_point->inSet = 0; /* extract the coordinates from point */ AssertIntEQ(EC_POINT_get_affine_coordinates_GFp(group, new_point, X, Y, ctx), WOLFSSL_SUCCESS);