Fix potential memory leak on failure of dsa_gen_init()

When dsa_gen_set_params()  returns 0, it could have duplicated the memory for the parameter
OSSL_PKEY_PARAM_FFC_DIGEST already in gctx->mdname, leading to a memory leak.

Allocated here: 47a80fd203/providers/implementations/keymgmt/dsa_kmgmt.c (L524)
Can return 0 here: 47a80fd203/providers/implementations/keymgmt/dsa_kmgmt.c (L529-L536)

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Paul Dale <ppzgs1@gmail.com>
Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/26016)
This commit is contained in:
Niels Dossche 2024-11-20 20:22:43 +01:00 committed by Tomas Mraz
parent ea5817854c
commit d7e8f6f781

View File

@ -430,7 +430,7 @@ static void *dsa_gen_init(void *provctx, int selection,
OSSL_FIPS_IND_INIT(gctx)
}
if (!dsa_gen_set_params(gctx, params)) {
OPENSSL_free(gctx);
dsa_gen_cleanup(gctx);
gctx = NULL;
}
return gctx;