fix type conversion issue

Signed-off-by: Jerry Yu <jerry.h.yu@arm.com>
This commit is contained in:
Jerry Yu 2022-04-07 10:51:55 +08:00
parent ac5ca5a0ea
commit e01304f6d8
2 changed files with 12 additions and 3 deletions

View file

@ -518,7 +518,11 @@ static int ssl_write_client_hello_body( mbedtls_ssl_context *ssl,
#if defined(MBEDTLS_SSL_PROTO_TLS1_2) && defined(MBEDTLS_SSL_PROTO_DTLS)
if( ssl->conf->transport == MBEDTLS_SSL_TRANSPORT_DATAGRAM )
{
unsigned char cookie_len = 0;
#if !defined(MBEDTLS_SSL_PROTO_TLS1_3)
uint8_t cookie_len = 0;
#else
uint16_t cookie_len = 0;
#endif /* !MBEDTLS_SSL_PROTO_TLS1_3 */
if( handshake->cookie != NULL )
{
@ -529,7 +533,7 @@ static int ssl_write_client_hello_body( mbedtls_ssl_context *ssl,
}
MBEDTLS_SSL_CHK_BUF_PTR( p, end, cookie_len + 1 );
*p++ = cookie_len;
*p++ = ( unsigned char )cookie_len;
if( cookie_len > 0 )
{
memcpy( p, handshake->cookie, cookie_len );

View file

@ -1137,7 +1137,12 @@ static int ssl_parse_hello_verify_request( mbedtls_ssl_context *ssl )
{
const unsigned char *p = ssl->in_msg + mbedtls_ssl_hs_hdr_len( ssl );
uint16_t dtls_legacy_version;
unsigned char cookie_len;
#if !defined(MBEDTLS_SSL_PROTO_TLS1_3)
uint8_t cookie_len;
#else
uint16_t cookie_len;
#endif
MBEDTLS_SSL_DEBUG_MSG( 2, ( "=> parse hello verify request" ) );