From: Tomas Mraz Date: Wed, 8 Jun 2022 15:48:39 +0000 (+0200) Subject: sm2_dupctx: Avoid potential use after free of the md X-Git-Tag: openssl-3.2.0-alpha1~2542 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=926c698c6f0a197e0322d4617db0ecd0d40f6e06;p=thirdparty%2Fopenssl.git sm2_dupctx: Avoid potential use after free of the md Reviewed-by: Shane Lontis Reviewed-by: Matt Caswell (Merged from https://github.com/openssl/openssl/pull/18494) --- diff --git a/providers/implementations/asymciphers/sm2_enc.c b/providers/implementations/asymciphers/sm2_enc.c index 9577d16e838..ddb2cfc14a1 100644 --- a/providers/implementations/asymciphers/sm2_enc.c +++ b/providers/implementations/asymciphers/sm2_enc.c @@ -138,6 +138,8 @@ static void *sm2_dupctx(void *vpsm2ctx) return NULL; *dstctx = *srcctx; + memset(&dstctx->md, 0, sizeof(dstctx->md)); + if (dstctx->key != NULL && !EC_KEY_up_ref(dstctx->key)) { OPENSSL_free(dstctx); return NULL;