diff --git a/src/quic.c b/src/quic.c index 64cf14fc86..918b96751d 100644 --- a/src/quic.c +++ b/src/quic.c @@ -154,17 +154,15 @@ static int quic_record_append(WOLFSSL *ssl, QuicRecord *qr, const uint8_t *data, } } - if (quic_record_complete(qr) || len == 0) { - return 0; - } - - missing = qr->len - qr->end; - if (len > missing) { - len = missing; + 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; } - 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 c58625db48..1b1f7556cd 100644 --- a/tests/quic.c +++ b/tests/quic.c @@ -287,7 +287,10 @@ 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, len, 0)); + 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) + ); len = fake_record(2, 1523, lbuffer); AssertTrue(provide_data(ssl, wolfssl_encryption_handshake, lbuffer, len, 0)); len = fake_record(2, 1, lbuffer);