Skip to content

Commit 8de2949

Browse files
committed
mbedtls: Add bounds check before length read
This is part of the patch for CVE-2018-9989. Cherry-picked from Mbed-TLS/mbedtls@740b218 Ref. #1860
1 parent ffab608 commit 8de2949

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

components/mbedtls/library/ssl_cli.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2049,6 +2049,12 @@ static int ssl_parse_server_psk_hint( mbedtls_ssl_context *ssl,
20492049
*
20502050
* opaque psk_identity_hint<0..2^16-1>;
20512051
*/
2052+
if( (*p) > end - 2 )
2053+
{
2054+
MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad server key exchange message "
2055+
"(psk_identity_hint length)" ) );
2056+
return( MBEDTLS_ERR_SSL_BAD_HS_SERVER_KEY_EXCHANGE );
2057+
}
20522058
len = (*p)[0] << 8 | (*p)[1];
20532059
*p += 2;
20542060

0 commit comments

Comments
 (0)