From 881ebc7ce88b66f381a6be6ee556ee3d2d2834fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20P=C3=A9gouri=C3=A9-Gonnard?= Date: Thu, 10 Apr 2025 12:35:58 +0200 Subject: [PATCH] Fix record insertion MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We were not making enough room. We want to move everything from the place where we are going to insert the new record. This was not causing failures because the code does not look at the content after the inserted record, because it correctly returns an error when seeing the inserted record. But as a matter on principle, the test code should be doing what it says: just insert a new record but leave a valid fragment after it. Signed-off-by: Manuel Pégourié-Gonnard --- tests/suites/test_suite_ssl.function | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/suites/test_suite_ssl.function b/tests/suites/test_suite_ssl.function index 8563fbe2c4..f189affe86 100644 --- a/tests/suites/test_suite_ssl.function +++ b/tests/suites/test_suite_ssl.function @@ -200,14 +200,14 @@ static int recombine_insert_record(mbedtls_test_ssl_buffer *buf, TEST_LE_U(buf->content_length + 2 * header_length + inserted_content_length, buf->capacity); - /* Make room for an empty record and a record header */ + /* Make room for the inserted record and a record header for the fragment */ size_t inserted_record_start = header_length + offset; size_t inserted_content_start = inserted_record_start + header_length; size_t tail_record_start = inserted_content_start + inserted_content_length; size_t tail_content_start = tail_record_start + header_length; memmove(buf->buffer + tail_content_start, - buf->buffer + tail_record_start, - buf->content_length - tail_record_start); + buf->buffer + inserted_record_start, + buf->content_length - inserted_record_start); buf->content_length += 2 * header_length; /* Construct the inserted record based on the existing one */