From 0aead12706a1d340c014bfd1edc93b1aa0746638 Mon Sep 17 00:00:00 2001 From: Ronald Cron Date: Wed, 21 Feb 2024 14:46:56 +0100 Subject: [PATCH] ssl_client2: Improve loop writing early data Signed-off-by: Ronald Cron --- programs/ssl/ssl_client2.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/programs/ssl/ssl_client2.c b/programs/ssl/ssl_client2.c index bcf44b7f8..0597298c6 100644 --- a/programs/ssl/ssl_client2.c +++ b/programs/ssl/ssl_client2.c @@ -3050,7 +3050,7 @@ reconnect: while ((ret = mbedtls_ssl_write_early_data(&ssl, buf + written, len - written)) < 0) { if (ret == MBEDTLS_ERR_SSL_CANNOT_WRITE_EARLY_DATA) { - break; + goto end_of_early_data; } if (ret != MBEDTLS_ERR_SSL_WANT_READ && ret != MBEDTLS_ERR_SSL_WANT_WRITE && @@ -3069,15 +3069,14 @@ reconnect: #endif } } - if (ret == MBEDTLS_ERR_SSL_CANNOT_WRITE_EARLY_DATA) { - break; - } frags++; written += ret; } while (written < len); } +end_of_early_data: + buf[written] = '\0'; mbedtls_printf( " %" MBEDTLS_PRINTF_SIZET " bytes of early data written in %" MBEDTLS_PRINTF_SIZET " fragments\n\n%s\n",