From: Ingo Franzki Date: Tue, 20 Aug 2024 09:35:20 +0000 (+0200) Subject: s390x: Fix memory leak in s390x_HMAC_CTX_copy() X-Git-Tag: openssl-3.4.0-alpha1~61 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=19b87d2d2b022c20dd9043c3b6d021315011b45f;p=thirdparty%2Fopenssl.git s390x: Fix memory leak in s390x_HMAC_CTX_copy() When s390x_HMAC_CTX_copy() is called, but the destination context already has a buffer allocated, it is not freed before duplicating the buffer from the source context. Signed-off-by: Ingo Franzki Reviewed-by: Paul Dale Reviewed-by: Shane Lontis (Merged from https://github.com/openssl/openssl/pull/25238) --- diff --git a/crypto/hmac/hmac_s390x.c b/crypto/hmac/hmac_s390x.c index 1124d9bc5d7..8b0da0d59d1 100644 --- a/crypto/hmac/hmac_s390x.c +++ b/crypto/hmac/hmac_s390x.c @@ -263,6 +263,7 @@ int s390x_HMAC_CTX_copy(HMAC_CTX *dctx, HMAC_CTX *sctx) memcpy(&dctx->plat.s390x.param, &sctx->plat.s390x.param, sizeof(dctx->plat.s390x.param)); + OPENSSL_clear_free(dctx->plat.s390x.buf, dctx->plat.s390x.size); dctx->plat.s390x.buf = NULL; if (sctx->plat.s390x.buf != NULL) { dctx->plat.s390x.buf = OPENSSL_memdup(sctx->plat.s390x.buf,