This is an automated email from the ASF dual-hosted git repository. zwoop pushed a commit to branch 8.1.x in repository https://gitbox.apache.org/repos/asf/trafficserver.git
commit b64730175ff2f96c121e3ee1d91ceb64e9f6f8b7 Author: Susan Hinrichs <[email protected]> AuthorDate: Mon Feb 24 17:39:14 2020 +0000 Adjust consume logic in data frame read (cherry picked from commit 4094cdad2db9b92ecd4af972f95e253d30281ad3) --- proxy/http2/Http2ConnectionState.cc | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/proxy/http2/Http2ConnectionState.cc b/proxy/http2/Http2ConnectionState.cc index 1293619..fa5437d 100644 --- a/proxy/http2/Http2ConnectionState.cc +++ b/proxy/http2/Http2ConnectionState.cc @@ -181,13 +181,18 @@ rcv_data_frame(Http2ConnectionState &cstate, const Http2Frame &frame) myreader->consume(HTTP2_DATA_PADLEN_LEN); } - while (nbytes < unpadded_length) { + if (nbytes < unpadded_length) { size_t read_len = BUFFER_SIZE_FOR_INDEX(buffer_size_index[HTTP2_FRAME_TYPE_DATA]); if (nbytes + read_len > unpadded_length) { read_len -= nbytes + read_len - unpadded_length; } - nbytes += writer->write(myreader, read_len); - myreader->consume(nbytes); + unsigned int num_written = writer->write(myreader, read_len); + if (num_written != read_len) { + myreader->writer()->dealloc_reader(myreader); + return Http2Error(Http2ErrorClass::HTTP2_ERROR_CLASS_STREAM, Http2ErrorCode::HTTP2_ERROR_INTERNAL_ERROR); + } + nbytes += num_written; + myreader->consume(num_written); } myreader->writer()->dealloc_reader(myreader);
