Skip to content

Commit

Permalink
Merge pull request #8340 from julek-wolfssl/gh/8156
Browse files Browse the repository at this point in the history
quic_record_append: return correct code
  • Loading branch information
JacobBarthelmeh authored Jan 10, 2025
2 parents 0e3020b + bc12dad commit 21bdb76
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
18 changes: 8 additions & 10 deletions src/quic.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
5 changes: 4 additions & 1 deletion tests/quic.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 21bdb76

Please sign in to comment.