Prevent arithmetic overflow on bounds check

This commit is contained in:
Krzysztof Stachowiak 2018-03-14 11:50:54 +01:00
parent ce0d3ca128
commit c86b880411

View file

@ -2246,7 +2246,7 @@ static int ssl_parse_server_key_exchange( mbedtls_ssl_context *ssl )
sig_len = ( p[0] << 8 ) | p[1];
p += 2;
if( end != p + sig_len )
if( p != end - sig_len )
{
MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad server key exchange message" ) );
return( MBEDTLS_ERR_SSL_BAD_HS_SERVER_KEY_EXCHANGE );