Assign s->s3.tmp.pkey after ssl_derive succeeds and free skey on failure
to avoid a dangling state.
Signed-off-by: Joshua Rogers <MegaManSec@users.noreply.github.com>
Reviewed-by: Saša Nedvědický <sashan@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/28878)
/*
* This causes the crypto state to be updated based on the derived keys
*/
- s->s3.tmp.pkey = skey;
if (ssl_derive(s, skey, ckey, 1) == 0) {
/* SSLfatal() already called */
+ EVP_PKEY_free(skey);
return EXT_RETURN_FAIL;
}
+ s->s3.tmp.pkey = skey;
} else {
/* KEM mode */
unsigned char *ct = NULL;