From e923d4c1512a8df5c5b0ade2c01842dfef021549 Mon Sep 17 00:00:00 2001 From: Marco Oliverio Date: Wed, 7 Feb 2024 14:48:12 +0100 Subject: [PATCH] tls13: read_early_data: set outSz to 0 if no early data If not data is read, set outSz to 0. This way the caller can detect if no early data was read. --- src/tls13.c | 1 + tests/api.c | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/tls13.c b/src/tls13.c index cf4a5a186..124f9a1b5 100644 --- a/src/tls13.c +++ b/src/tls13.c @@ -14357,6 +14357,7 @@ int wolfSSL_read_early_data(WOLFSSL* ssl, void* data, int sz, int* outSz) if (!IsAtLeastTLSv1_3(ssl->version)) return BAD_FUNC_ARG; + *outSz = 0; #ifndef NO_WOLFSSL_SERVER if (ssl->options.side == WOLFSSL_CLIENT_END) return SIDE_ERROR; diff --git a/tests/api.c b/tests/api.c index d5d710ef2..193058623 100644 --- a/tests/api.c +++ b/tests/api.c @@ -69268,6 +69268,7 @@ static int test_tls13_early_data(void) ExpectFalse(wolfSSL_is_init_finished(ssl_s)); ExpectIntEQ(wolfSSL_read_early_data(ssl_s, msgBuf, sizeof(msgBuf), &read), 0); + ExpectIntEQ(read, 0); ExpectTrue(wolfSSL_is_init_finished(ssl_s)); ExpectIntEQ(wolfSSL_connect(ssl_c), WOLFSSL_SUCCESS); @@ -69278,7 +69279,7 @@ static int test_tls13_early_data(void) ExpectFalse(wolfSSL_is_init_finished(ssl_s)); ExpectIntEQ(wolfSSL_read_early_data(ssl_s, msgBuf, sizeof(msgBuf), &read), 0); - + ExpectIntEQ(read, 0); ExpectTrue(wolfSSL_is_init_finished(ssl_s)); /* Read server 0.5-RTT data */