]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
s390x: Fix memory leak in s390x_HMAC_CTX_copy()
authorIngo Franzki <ifranzki@linux.ibm.com>
Tue, 20 Aug 2024 09:35:20 +0000 (11:35 +0200)
committerTomas Mraz <tomas@openssl.org>
Fri, 23 Aug 2024 07:11:01 +0000 (09:11 +0200)
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 <ifranzki@linux.ibm.com>
Reviewed-by: Paul Dale <ppzgs1@gmail.com>
Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/25238)

crypto/hmac/hmac_s390x.c

index 1124d9bc5d76015dafa9101a352f099f525a009b..8b0da0d59d19c6fb3e6b8d794d3f1b245a8e6de9 100644 (file)
@@ -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,