Skip to content

Commit

Permalink
multiplexer: fix consume of too many bytes (#11499)
Browse files Browse the repository at this point in the history
IOBufferReader::consume contractually assumes that all callers of it
will not consume more bytes than read_avail for the buffer chain. This
adds a debug assertion for this and fixes multiplexer so that it doesn't
violate this invariant.
  • Loading branch information
bneradt authored Aug 7, 2024
1 parent 9c6ae2e commit 6774984
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
2 changes: 2 additions & 0 deletions plugins/multiplexer/fetcher.h
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,8 @@ template <class T> struct HttpTransaction {
self->t_.header(self->parser_.buffer_, self->parser_.location_);
self->parsingHeaders_ = false;
}
// Parsing headers will indirectly read from our reader. Update available accordingly.
available = TSIOBufferReaderAvail(self->in_->reader);
}
if (!self->parsingHeaders_) {
if (self->chunkDecoder_ != NULL) {
Expand Down
1 change: 1 addition & 0 deletions src/iocore/eventsystem/P_IOBuffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -551,6 +551,7 @@ IOBufferReader::is_read_avail_more_than(int64_t size)
TS_INLINE void
IOBufferReader::consume(int64_t n)
{
ink_assert(read_avail() >= n);
start_offset += n;
if (size_limit != INT64_MAX) {
size_limit -= n;
Expand Down

0 comments on commit 6774984

Please sign in to comment.