From d4c654205b396bc094101924cec5c70f3c1c43a1 Mon Sep 17 00:00:00 2001 From: Daniel Pouzzner Date: Fri, 10 Jan 2025 17:38:02 -0600 Subject: [PATCH] Revert "quic_record_append: return correct code" This reverts commit bc12dad041594366a232a0022a04024b6254390d. This commit broke builds that combine QUIC and PQ -- known failures are pq-all-valgrind-unittest, pq-hybrid-all-rpk, pq-hybrid-all-rpk-valgrind-unittest, quantum-safe-wolfssl-all-gcc-latest, quantum-safe-wolfssl-all-g++-latest, quantum-safe-wolfssl-all-fortify-source-asm, quantum-safe-wolfssl-all-fortify-source-asm-noasm, and quantum-safe-wolfssl-all-intelasm-sp-asm-valgrind. Note that the unit.test asserts added by this commit fail both before and after reversion. --- src/quic.c | 18 ++++++++++-------- tests/quic.c | 5 +---- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/src/quic.c b/src/quic.c index 918b96751d..64cf14fc86 100644 --- a/src/quic.c +++ b/src/quic.c @@ -154,15 +154,17 @@ static int quic_record_append(WOLFSSL *ssl, QuicRecord *qr, const uint8_t *data, } } - if (!quic_record_complete(qr) && len != 0) { - missing = qr->len - qr->end; - if (len > missing) { - len = missing; - } - XMEMCPY(qr->data + qr->end, data, len); - qr->end += (word32)len; - consumed += len; + if (quic_record_complete(qr) || len == 0) { + return 0; + } + + missing = qr->len - qr->end; + if (len > missing) { + len = missing; } + XMEMCPY(qr->data + qr->end, data, len); + qr->end += (word32)len; + consumed += len; cleanup: *pconsumed = (ret == WOLFSSL_SUCCESS) ? consumed : 0; diff --git a/tests/quic.c b/tests/quic.c index 1b1f7556cd..c58625db48 100644 --- a/tests/quic.c +++ b/tests/quic.c @@ -287,10 +287,7 @@ static int test_provide_quic_data(void) { */ AssertNotNull(ssl = wolfSSL_new(ctx)); len = fake_record(1, 100, lbuffer); - AssertTrue(provide_data(ssl, wolfssl_encryption_initial, lbuffer, 1, 0)); - AssertTrue(provide_data(ssl, wolfssl_encryption_initial, lbuffer+1, 3, 0)); - AssertTrue(provide_data(ssl, wolfssl_encryption_initial, lbuffer+4, len, 0) - ); + AssertTrue(provide_data(ssl, wolfssl_encryption_initial, lbuffer, len, 0)); len = fake_record(2, 1523, lbuffer); AssertTrue(provide_data(ssl, wolfssl_encryption_handshake, lbuffer, len, 0)); len = fake_record(2, 1, lbuffer);