Avoid memory leak in hmac_ctx_new (OpenSSL 3.0 only)
PATCH 1/1 Avoid memory leak in hmac_ctx_new (OpenSSL 3.0 only)
From: Selva Nair <[email protected]...>
In OpenSSL 3.0, fetched algorithms must be freed (down referenced). In this case, though EVP_MAC_CTX_new() keeps a reference to 'hmac', it up-refs it. So we have to free it here before return.
(Tested using an enable-asan build).
--- src/openvpn/crypto_openssl.c | 3 +++ 1 file changed, 3 insertions(+)
src/openvpn/crypto_openssl.c +3 -0
@@ -1063,6 +1063,9 @@ hmac_ctx_new(void)EVP_MAC *hmac =EVP_MAC_fetch (NULL ,"HMAC" ,NULL ); ctx->ctx =EVP_MAC_CTX_new (hmac);check_malloc_return (ctx->ctx); + +EVP_MAC_free (hmac); +return ctx; }
Signature · 1 line
2.30.2
Am 30.10.21 um 20:57 schrieb [email protected]...:
Quoted 9 lines
From: Selva Nair <[email protected]...>
In OpenSSL 3.0, fetched algorithms must be freed (down referenced). In this case, though
EVP_MAC_CTX_new()keeps a reference to 'hmac', it up-refs it. So we have to free it here before return.(Tested using an enable-asan build).
Thanks. I overlooked freeing of fetched algorithms. I probably need to look at the fetch patch again too :/
Arne
I have not done "real" testing, just "compile and make check" on ossl 3.0.0 - but if you and Arne agree, this is definitely good enough for me :-)
Your patch has been applied to the master branch.
commit 31e200f807033ac27566bf37a8d9d32820600a83
Author: Selva Nair Date: Sat Oct 30 14:57:56 2021 -0400
Avoid memory leak in hmac_ctx_new (OpenSSL 3.0 only)
Signed-off-by: Selva Nair <[email protected]...>
Acked-by: Arne Schwabe <[email protected]...>
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg23080.html
Signed-off-by: Gert Doering <[email protected]...>--
kind regards,
Gert Doering