Skip to content

Commit

Permalink
Fix a memleak in prepare_rsa_params
Browse files Browse the repository at this point in the history
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 #22061)
  • Loading branch information
bernd-edlinger authored and t8m committed Sep 13, 2023
1 parent 123c858 commit 46def82
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion providers/implementations/encode_decode/encode_key2any.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

/*
Expand Down

0 comments on commit 46def82

Please sign in to comment.