Skip to content

Commit 845e2f7

Browse files
committed
added check if the buf is at least RECORD_HEADER_SZ
when adding the record headers through quic
1 parent ac459e3 commit 845e2f7

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

src/quic.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,12 @@ static word32 quic_record_transfer(QuicRecord* qr, byte* buf, word32 sz)
197197
if (len <= 0) {
198198
return 0;
199199
}
200+
201+
/* We check if the buf is at least RECORD_HEADER_SZ */
202+
if (sz < RECORD_HEADER_SZ) {
203+
return -1;
204+
}
205+
200206
if (qr->rec_hdr_remain == 0) {
201207
/* start a new TLS record */
202208
rlen = (qr->len <= (word32)MAX_RECORD_SIZE) ?
@@ -774,6 +780,11 @@ int wolfSSL_quic_receive(WOLFSSL* ssl, byte* buf, word32 sz)
774780
n = 0;
775781
if (ssl->quic.input_head) {
776782
n = quic_record_transfer(ssl->quic.input_head, buf, sz);
783+
784+
/* record too small to be fit into a RecordLayerHeader struct. */
785+
if (n == -1) {
786+
return -1;
787+
}
777788
if (quic_record_done(ssl->quic.input_head)) {
778789
QuicRecord* qr = ssl->quic.input_head;
779790
ssl->quic.input_head = qr->next;

0 commit comments

Comments
 (0)