Avoid segfault in SSL_export_keying_material if there is no session
authorTomas Mraz <tmraz@fedoraproject.org>
Thu, 6 Aug 2020 09:20:43 +0000 (11:20 +0200)
committerTomas Mraz <tmraz@fedoraproject.org>
Thu, 13 Aug 2020 08:17:10 +0000 (10:17 +0200)
Fixes #12588

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

ssl/ssl_lib.c

index f957664a486612a3e62560b4ee484d2883c8e6c8..c72341547afd47d0492d355fcdd778fc534b7b14 100644 (file)
@@ -3054,7 +3054,8 @@ int SSL_export_keying_material(SSL *s, unsigned char *out, size_t olen,
                                const unsigned char *context, size_t contextlen,
                                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 s->method->ssl3_enc->export_keying_material(s, out, olen, label,