diff options
author | Bernd Edlinger <bernd.edlinger@hotmail.de> | 2023-09-11 12:34:02 +0200 |
---|---|---|
committer | Tomas Mraz <tomas@openssl.org> | 2023-09-13 07:46:46 +0200 |
commit | 46def829afa4d8bed8f53d484bdf842d65f0e176 (patch) | |
tree | d2ac63852a46a1bdaa15df07be3b749740759f7b /providers | |
parent | 123c85864fa7fe97d8ae3a09989d410501d957a5 (diff) |
Fix a memleak in prepare_rsa_params
This affects only RSA-PSS keys with params using
negative salt legth, or in case of out of memory.
This fixes a memory leak reported in #22049.
Reviewed-by: Hugo Landau <hlandau@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/22061)
Diffstat (limited to 'providers')
-rw-r--r-- | providers/implementations/encode_decode/encode_key2any.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/providers/implementations/encode_decode/encode_key2any.c b/providers/implementations/encode_decode/encode_key2any.c index c1b0dea780..ae6d7d0a68 100644 --- a/providers/implementations/encode_decode/encode_key2any.c +++ b/providers/implementations/encode_decode/encode_key2any.c @@ -856,14 +856,17 @@ static int prepare_rsa_params(const void *rsa, int nid, int save, case 1: if ((str = OPENSSL_malloc(str_sz)) == NULL || !WPACKET_init_der(&pkt, str, str_sz)) { + WPACKET_cleanup(&pkt); goto err; } break; } if (!ossl_DER_w_RSASSA_PSS_params(&pkt, -1, pss) || !WPACKET_finish(&pkt) - || !WPACKET_get_total_written(&pkt, &str_sz)) + || !WPACKET_get_total_written(&pkt, &str_sz)) { + WPACKET_cleanup(&pkt); goto err; + } WPACKET_cleanup(&pkt); /* |