@@ -619,13 +619,29 @@ xqc_process_stream_frame(xqc_connection_t *conn, xqc_packet_in_t *packet_in)
619
619
return ret ;
620
620
}
621
621
622
+ xqc_int_t
623
+ xqc_check_crypto_frame_data_buffer_exceed (xqc_stream_t * stream , xqc_stream_frame_t * stream_frame , uint64_t threshold )
624
+ {
625
+ if (stream_frame -> data_offset + stream_frame -> data_length > stream -> stream_data_in .next_read_offset + threshold ) {
626
+ return - XQC_ELIMIT ;
627
+ }
628
+ return XQC_OK ;
629
+ }
622
630
623
631
xqc_int_t
624
632
xqc_insert_crypto_frame (xqc_connection_t * conn , xqc_stream_t * stream , xqc_stream_frame_t * stream_frame )
625
633
{
626
634
unsigned char inserted = 0 ;
627
635
xqc_list_head_t * pos ;
628
636
xqc_stream_frame_t * frame ;
637
+ xqc_int_t ret ;
638
+ ret = xqc_check_crypto_frame_data_buffer_exceed (stream , stream_frame , XQC_CONN_MAX_CRYPTO_DATA_TOTAL_LEN );
639
+ if (ret != XQC_OK ) {
640
+ XQC_CONN_ERR (conn , TRA_CRYPTO_BUFFER_EXCEEDED );
641
+ xqc_log (conn -> log , XQC_LOG_ERROR ,
642
+ "|crypto frame data buffer exceed|" );
643
+ return ret ;
644
+ }
629
645
xqc_list_for_each_reverse (pos , & stream -> stream_data_in .frames_tailq ) {
630
646
frame = xqc_list_entry (pos , xqc_stream_frame_t , sf_list );
631
647
@@ -697,7 +713,7 @@ xqc_process_crypto_frame(xqc_connection_t *conn, xqc_packet_in_t *packet_in)
697
713
if (ret != XQC_OK ) {
698
714
xqc_log (conn -> log , XQC_LOG_ERROR , "|xqc_insert_crypto_frame error|" );
699
715
xqc_destroy_stream_frame (stream_frame );
700
- return -1 ;
716
+ return ret ;
701
717
}
702
718
703
719
ret = xqc_read_crypto_stream (stream );
@@ -1508,8 +1524,8 @@ xqc_process_path_challenge_frame(xqc_connection_t *conn, xqc_packet_in_t *packet
1508
1524
}
1509
1525
1510
1526
xqc_log (conn -> log , XQC_LOG_DEBUG ,
1511
- "|path:%ui|state:%d|RECV path_challenge_data:%s|cid:%s|" ,
1512
- path -> path_id , path -> path_state ,
1527
+ "|path:%ui|state:%d|RECV path_challenge_data:%* s|cid:%s|" ,
1528
+ path -> path_id , path -> path_state , XQC_PATH_CHALLENGE_DATA_LEN ,
1513
1529
path_challenge_data , xqc_dcid_str (conn -> engine , & packet_in -> pi_pkt .pkt_dcid ));
1514
1530
1515
1531
ret = xqc_write_path_response_frame_to_packet (conn , path , path_challenge_data );
@@ -2110,4 +2126,4 @@ xqc_process_repair_frame(xqc_connection_t *conn, xqc_packet_in_t *packet_in)
2110
2126
return XQC_OK ;
2111
2127
}
2112
2128
2113
- #endif
2129
+ #endif
0 commit comments