ssl: fix coverity 1451515: out of bounds memory access
authorPauli <ppzgs1@gmail.com>
Wed, 17 Mar 2021 02:00:42 +0000 (12:00 +1000)
committerPauli <ppzgs1@gmail.com>
Thu, 18 Mar 2021 11:19:15 +0000 (21:19 +1000)
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/14585)

ssl/statem/statem_clnt.c

index e7917be4fbb1e436e78efb6ee1cbb1f332c67ae9..666ee43363c4867030ddb22ba5e5bf4cc7424f52 100644 (file)
@@ -2767,6 +2767,7 @@ static int tls_construct_cke_psk_preamble(SSL *s, WPACKET *pkt)
 
     if (psklen > PSK_MAX_PSK_LEN) {
         SSLfatal(s, SSL_AD_HANDSHAKE_FAILURE, ERR_R_INTERNAL_ERROR);
+        psklen = PSK_MAX_PSK_LEN;   /* Avoid overrunning the array on cleanse */
         goto err;
     } else if (psklen == 0) {
         SSLfatal(s, SSL_AD_HANDSHAKE_FAILURE, SSL_R_PSK_IDENTITY_NOT_FOUND);