Check length before reading handshake header

This commit is contained in:
Manuel Pégourié-Gonnard 2014-09-03 11:01:14 +02:00 committed by Paul Bakker
parent d9ba0d96b6
commit 9d1d7196e4
2 changed files with 23 additions and 5 deletions

View file

@ -784,7 +784,8 @@ struct _ssl_context
(equal to in_left if none) */
#endif
size_t in_hslen; /*!< current handshake message length */
size_t in_hslen; /*!< current handshake message length,
including the handshake header */
int nb_zero; /*!< # of 0-length encrypted messages */
int record_read; /*!< record is already present */
@ -1948,6 +1949,17 @@ static inline size_t ssl_hdr_len( const ssl_context *ssl )
return( 5 );
}
static inline size_t ssl_hs_hdr_len( const ssl_context *ssl )
{
#if defined(POLARSSL_SSL_PROTO_DTLS)
if( ssl->transport == SSL_TRANSPORT_DATAGRAM )
return( 12 );
#else
((void) ssl);
#endif
return( 4 );
}
/* constant-time buffer comparison */
static inline int safer_memcmp( const void *a, const void *b, size_t n )
{