Skip to content

Commit

Permalink
QUIC - added safety check for zero bytes consumed
Browse files Browse the repository at this point in the history
  • Loading branch information
nbridge-jump committed Feb 21, 2024
1 parent 7fbb63d commit 4a45eec
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/waltz/quic/fd_quic.c
Original file line number Diff line number Diff line change
Expand Up @@ -1621,7 +1621,7 @@ fd_quic_handle_v1_initial( fd_quic_t * quic,
ulong frame_sz = body_sz - pkt_number_sz - FD_QUIC_CRYPTO_TAG_SZ; /* total size of all frames in packet */
while( frame_sz != 0UL ) {
rc = fd_quic_handle_v1_frame( quic, conn, pkt, frame_ptr, frame_sz, &conn->frame_union );
if( rc == FD_QUIC_PARSE_FAIL ) {
if( FD_UNLIKELY( rc == FD_QUIC_PARSE_FAIL ) ) {
return FD_QUIC_PARSE_FAIL;
}

Expand Down Expand Up @@ -1823,11 +1823,11 @@ fd_quic_handle_v1_handshake(
ulong frame_sz = body_sz - pkt_number_sz - FD_QUIC_CRYPTO_TAG_SZ; /* total size of all frames in packet */
while( frame_sz != 0UL ) {
rc = fd_quic_handle_v1_frame( quic, conn, pkt, frame_ptr, frame_sz, &conn->frame_union );
if( rc == FD_QUIC_PARSE_FAIL ) {
if( FD_UNLIKELY( rc == FD_QUIC_PARSE_FAIL ) ) {
return FD_QUIC_PARSE_FAIL;
}

if( FD_UNLIKELY( rc > frame_sz ) ) {
if( FD_UNLIKELY( rc == 0UL || rc > frame_sz ) ) {
fd_quic_conn_close( conn, FD_QUIC_CONN_REASON_PROTOCOL_VIOLATION );
return FD_QUIC_PARSE_FAIL;
}
Expand Down Expand Up @@ -2162,12 +2162,12 @@ fd_quic_handle_v1_one_rtt( fd_quic_t * quic,
ulong frame_sz = cur_sz - pn_offset - pkt_number_sz - FD_QUIC_CRYPTO_TAG_SZ; /* total size of all frames in packet */
while( frame_sz != 0UL ) {
rc = fd_quic_handle_v1_frame( quic, conn, pkt, frame_ptr, frame_sz, &conn->frame_union );
if( rc == FD_QUIC_PARSE_FAIL ) {
if( FD_UNLIKELY( rc == FD_QUIC_PARSE_FAIL ) ) {
FD_DEBUG( FD_LOG_DEBUG(( "frame failed to parse" )) );
return FD_QUIC_PARSE_FAIL;
}

if( FD_UNLIKELY( rc==0UL || rc>frame_sz ) ) {
if( FD_UNLIKELY( rc == 0UL || rc > frame_sz ) ) {
fd_quic_conn_close( conn, FD_QUIC_CONN_REASON_PROTOCOL_VIOLATION );
return FD_QUIC_PARSE_FAIL;
}
Expand Down

0 comments on commit 4a45eec

Please sign in to comment.