From b4a5606e2d607062fc5acd6d91c694f3de6cab5f Mon Sep 17 00:00:00 2001 From: Hanno Becker Date: Tue, 30 Apr 2019 14:07:31 +0100 Subject: [PATCH] Make integer truncation explicit in mbedtls_ssl_set_cid() --- library/ssl_tls.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/library/ssl_tls.c b/library/ssl_tls.c index fe985e8e3..d0cab160b 100644 --- a/library/ssl_tls.c +++ b/library/ssl_tls.c @@ -136,7 +136,9 @@ int mbedtls_ssl_set_cid( mbedtls_ssl_context *ssl, } memcpy( ssl->own_cid, own_cid, own_cid_len ); - ssl->own_cid_len = own_cid_len; + /* Truncation is not an issue here because + * MBEDTLS_SSL_CID_IN_LEN_MAX at most 255. */ + ssl->own_cid_len = (uint8_t) own_cid_len; MBEDTLS_SSL_DEBUG_BUF( 3, "Own CID", own_cid, own_cid_len ); return( 0 );