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);