diff options
| author | Zijie Zhao <[email protected]> | 2026-01-15 22:04:49 +0100 |
|---|---|---|
| committer | Tomas Mraz <[email protected]> | 2026-01-20 20:01:40 +0100 |
| commit | 60b0bbc5db752f02eee4555b358ec6a39a0ef3a9 (patch) | |
| tree | 2fdbfe47b65d01bcca8c73939c28f7d852c2df8e | |
| parent | Fix double-free in TLS1-PRF KDF when digest change fails (diff) | |
| download | openssl-60b0bbc5db752f02eee4555b358ec6a39a0ef3a9.tar.gz openssl-60b0bbc5db752f02eee4555b358ec6a39a0ef3a9.zip | |
Fix `EVP_KEYMGMT` leak in `evp_pkey_signature_init()` error paths
Early returns when signature/key type are incompatible bypass cleanup
of `tmp_keymgmt` allocated via `evp_keymgmt_fetch_from_prov()`. Use goto
to ensure `EVP_KEYMGMT_free()` is called on all error paths.
Reviewed-by: Paul Dale <[email protected]>
Reviewed-by: Eugene Syromiatnikov <[email protected]>
Reviewed-by: Tomas Mraz <[email protected]>
MergeDate: Tue Jan 20 19:01:17 2026
(Merged from https://github.com/openssl/openssl/pull/29651)
(cherry picked from commit c729de6ec370fd8d71aa525749662ccb192428f6)
| -rw-r--r-- | crypto/evp/signature.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/crypto/evp/signature.c b/crypto/evp/signature.c index f3c440c8eff..902586a26c6 100644 --- a/crypto/evp/signature.c +++ b/crypto/evp/signature.c @@ -553,7 +553,8 @@ static int evp_pkey_signature_init(EVP_PKEY_CTX *ctx, EVP_SIGNATURE *signature, break; if (*keytypes == NULL) { ERR_raise(ERR_LIB_EVP, EVP_R_SIGNATURE_TYPE_AND_KEY_TYPE_INCOMPATIBLE); - return -2; + ret = -2; + goto end; } } else { /* @@ -579,12 +580,13 @@ static int evp_pkey_signature_init(EVP_PKEY_CTX *ctx, EVP_SIGNATURE *signature, /* If none of the fallbacks helped, we're lost */ if (!ok) { ERR_raise(ERR_LIB_EVP, EVP_R_SIGNATURE_TYPE_AND_KEY_TYPE_INCOMPATIBLE); - return -2; + ret = -2; + goto end; } } if (!EVP_SIGNATURE_up_ref(signature)) - return 0; + goto err; } else { /* Without a pre-fetched signature, it must be figured out somehow */ ERR_set_mark(); |
