Avoid segfault in SSL_export_keying_material if there is no session

Fixes #12588

Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/12594)

(cherry picked from commit dffeec1c10)
This commit is contained in:
Tomas Mraz 2020-08-06 11:20:43 +02:00
parent ea7a58a606
commit 925a9d0a81
1 changed files with 2 additions and 1 deletions

View File

@ -2897,7 +2897,8 @@ int SSL_export_keying_material(SSL *s, unsigned char *out, size_t olen,
const unsigned char *context, size_t contextlen, const unsigned char *context, size_t contextlen,
int use_context) int use_context)
{ {
if (s->version < TLS1_VERSION && s->version != DTLS1_BAD_VER) if (s->session == NULL
|| (s->version < TLS1_VERSION && s->version != DTLS1_BAD_VER))
return -1; return -1;
return s->method->ssl3_enc->export_keying_material(s, out, olen, label, return s->method->ssl3_enc->export_keying_material(s, out, olen, label,