From 4e388286af740564055f004e99ae133f65b9aece Mon Sep 17 00:00:00 2001 From: Jerry Yu Date: Mon, 6 Sep 2021 21:28:08 +0800 Subject: [PATCH] fix usage of iteration Signed-off-by: Jerry Yu --- library/ssl_tls13_client.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/library/ssl_tls13_client.c b/library/ssl_tls13_client.c index fe2e6f850..b10e33bfb 100644 --- a/library/ssl_tls13_client.c +++ b/library/ssl_tls13_client.c @@ -132,9 +132,9 @@ static int ssl_tls13_write_client_hello_cipher_suites( unsigned char *end, size_t *olen ) { + unsigned char *p = buf; /* Iteration over the cipher_suites list */ const int *ciphersuite_list; unsigned char *cipher_suites_ptr; /* Start of the cipher_suites list */ - unsigned char *p; /* Iteration over the cipher_suites list */ size_t cipher_suites_len; *olen = 0 ; @@ -150,12 +150,11 @@ static int ssl_tls13_write_client_hello_cipher_suites( ciphersuite_list = ssl->conf->ciphersuite_list; /* Check there is space for the cipher suite list length (2 bytes). */ - MBEDTLS_SSL_CHK_BUF_PTR( buf, end, 2 ); + MBEDTLS_SSL_CHK_BUF_PTR( p, end, 2 ); + p += 2; /* Write cipher_suites */ - cipher_suites_ptr = buf + 2; - p = cipher_suites_ptr; - + cipher_suites_ptr = p; for ( size_t i = 0; ciphersuite_list[i] != 0; i++ ) { int cipher_suite = ciphersuite_list[i];