From: Bernd Edlinger Date: Wed, 8 Jun 2022 15:36:52 +0000 (+0200) Subject: Fix a use after free in error handling of hmac_dup X-Git-Tag: openssl-3.2.0-alpha1~2546 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=cec1699f1f54ba8b87f055776dc77b48dd37d5fa;p=thirdparty%2Fopenssl.git Fix a use after free in error handling of hmac_dup dst->digest needs to be zeroized in case HMAC_CTX_copy or ossl_prov_digest_copy return failure. Fixes #18493 Reviewed-by: Tomas Mraz Reviewed-by: Matt Caswell (Merged from https://github.com/openssl/openssl/pull/18502) --- diff --git a/providers/implementations/macs/hmac_prov.c b/providers/implementations/macs/hmac_prov.c index 2d6087b2c65..52ebb08b8f6 100644 --- a/providers/implementations/macs/hmac_prov.c +++ b/providers/implementations/macs/hmac_prov.c @@ -115,6 +115,7 @@ static void *hmac_dup(void *vsrc) *dst = *src; dst->ctx = ctx; dst->key = NULL; + memset(&dst->digest, 0, sizeof(dst->digest)); if (!HMAC_CTX_copy(dst->ctx, src->ctx) || !ossl_prov_digest_copy(&dst->digest, &src->digest)) {