Add the check for the return value of EVP_MD_CTX_get_size() to avoid invalid negative numbers.
Fixes: d0b79f8631 ("Add SM2 signature algorithm to default provider")
Signed-off-by: Jiasheng Jiang <jiasheng@purdue.edu>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Todd Short <todd.short@me.com>
Reviewed-by: Neil Horman <nhorman@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/23959)
if (psm2ctx == NULL
|| psm2ctx->mdctx == NULL
+ || EVP_MD_get_size(psm2ctx->md) <= 0
|| EVP_MD_get_size(psm2ctx->md) > (int)sizeof(digest))
return 0;