@@ -555,13 +555,14 @@ nghttp3_ssize nghttp3_conn_read_stream2(nghttp3_conn *conn, int64_t stream_id,
555555 return 0 ;
556556 }
557557
558+ if (fin ) {
559+ stream -> flags |= NGHTTP3_STREAM_FLAG_READ_EOF ;
560+ }
561+
558562 if (nghttp3_stream_uni (stream_id )) {
559563 return nghttp3_conn_read_uni (conn , stream , src , srclen , fin , ts );
560564 }
561565
562- if (fin ) {
563- stream -> flags |= NGHTTP3_STREAM_FLAG_READ_EOF ;
564- }
565566 return nghttp3_conn_read_bidi (conn , & bidi_nproc , stream , src , srclen , fin ,
566567 ts );
567568}
@@ -1126,6 +1127,13 @@ nghttp3_ssize nghttp3_conn_read_control(nghttp3_conn *conn,
11261127 break ;
11271128 }
11281129
1130+ /* Apply buffer limits here even if everything is in the input
1131+ buffer. */
1132+ if (rstate -> left > sizeof (conn -> rx .pri_fieldbuf )) {
1133+ rstate -> state = NGHTTP3_CTRL_STREAM_STATE_IGN_FRAME ;
1134+ break ;
1135+ }
1136+
11291137 conn -> rx .pri_fieldbuflen = 0 ;
11301138
11311139 rstate -> state = NGHTTP3_CTRL_STREAM_STATE_PRIORITY_UPDATE ;
@@ -1141,22 +1149,12 @@ nghttp3_ssize nghttp3_conn_read_control(nghttp3_conn *conn,
11411149 len = (size_t )nghttp3_min (rstate -> left , (uint64_t )(end - p ));
11421150 assert (len > 0 );
11431151 if (conn -> rx .pri_fieldbuflen == 0 && rstate -> left == len ) {
1144- /* Everything is in the input buffer. Apply same length
1145- limit we impose when buffering the field. */
1146- if (len > sizeof (conn -> rx .pri_fieldbuf )) {
1147- busy = 1 ;
1148- rstate -> state = NGHTTP3_CTRL_STREAM_STATE_IGN_FRAME ;
1149- break ;
1150- }
1151-
1152+ /* Everything is in the input buffer. */
11521153 pri_field_value = p ;
11531154 pri_field_valuelen = len ;
1154- } else if (len + conn -> rx .pri_fieldbuflen >
1155- sizeof (conn -> rx .pri_fieldbuf )) {
1156- busy = 1 ;
1157- rstate -> state = NGHTTP3_CTRL_STREAM_STATE_IGN_FRAME ;
1158- break ;
11591155 } else {
1156+ assert (len + conn -> rx .pri_fieldbuflen <= sizeof (conn -> rx .pri_fieldbuf ));
1157+
11601158 memcpy (conn -> rx .pri_fieldbuf + conn -> rx .pri_fieldbuflen , p , len );
11611159 conn -> rx .pri_fieldbuflen += len ;
11621160
@@ -1975,6 +1973,12 @@ int nghttp3_conn_on_settings_entry_received(nghttp3_conn *conn,
19751973 break ;
19761974 }
19771975
1976+ #if SIZE_MAX < UINT64_MAX
1977+ if (ent -> value > SIZE_MAX ) {
1978+ return NGHTTP3_ERR_H3_SETTINGS_ERROR ;
1979+ }
1980+ #endif /* SIZE_MAX < UINT64_MAX */
1981+
19781982 dest -> qpack_max_dtable_capacity = (size_t )ent -> value ;
19791983
19801984 nghttp3_qpack_encoder_set_max_dtable_capacity (& conn -> qenc ,
@@ -1989,6 +1993,12 @@ int nghttp3_conn_on_settings_entry_received(nghttp3_conn *conn,
19891993 break ;
19901994 }
19911995
1996+ #if SIZE_MAX < UINT64_MAX
1997+ if (ent -> value > SIZE_MAX ) {
1998+ return NGHTTP3_ERR_H3_SETTINGS_ERROR ;
1999+ }
2000+ #endif /* SIZE_MAX < UINT64_MAX */
2001+
19922002 dest -> qpack_blocked_streams = (size_t )ent -> value ;
19932003
19942004 nghttp3_qpack_encoder_set_max_blocked_streams (
@@ -2957,6 +2967,8 @@ int nghttp3_conn_set_client_stream_priority(nghttp3_conn *conn,
29572967 memcpy (buf , data , datalen );
29582968 }
29592969
2970+ assert (conn -> tx .ctrl );
2971+
29602972 rv = nghttp3_stream_frq_emplace (conn -> tx .ctrl , & fr );
29612973 if (rv != 0 ) {
29622974 nghttp3_mem_free (conn -> mem , buf );
0 commit comments