]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
Modify ssl_handshake_hash to call SSLfatal
authorTrev Larock <tlarock@juniper.net>
Fri, 28 May 2021 02:26:41 +0000 (02:26 +0000)
committerTomas Mraz <tomas@openssl.org>
Wed, 2 Jun 2021 07:59:30 +0000 (09:59 +0200)
When EVP_MD_CTX_new fails call SSLfatal before the goto err.
This resolves a state machine issue on the out of memory condition:
ssl/statem/statem.c:643: OpenSSL internal error: Assertion failed:
(s)->statem.in_init && (s)->statem.state == MSG_FLOW_ERROR

Fixes #15491.
CLA: trivial

Reviewed-by: Ben Kaduk <kaduk@mit.edu>
Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/15511)

ssl/ssl_lib.c

index 5501ecdb585e311f1f236cf4df455c3f812a9b77..e1c95ddc6064e872169427237be1eba8748a73e0 100644 (file)
@@ -4557,8 +4557,11 @@ int ssl_handshake_hash(SSL *s, unsigned char *out, size_t outlen,
     }
 
     ctx = EVP_MD_CTX_new();
-    if (ctx == NULL)
+    if (ctx == NULL) {
+        SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_SSL_HANDSHAKE_HASH,
+                 ERR_R_INTERNAL_ERROR);
         goto err;
+    }
 
     if (!EVP_MD_CTX_copy_ex(ctx, hdgst)
         || EVP_DigestFinal_ex(ctx, out, NULL) <= 0) {