This is an automated email from the ASF dual-hosted git repository.

eze pushed a commit to branch 9.2.x
in repository https://gitbox.apache.org/repos/asf/trafficserver.git


The following commit(s) were added to refs/heads/9.2.x by this push:
     new d511aa5cfe multiplexer: fix consume of too many bytes (#11499) (#11965)
d511aa5cfe is described below

commit d511aa5cfe83ed294b6c8b373bacd43f011ed8f3
Author: Evan Zelkowitz <[email protected]>
AuthorDate: Fri Jan 17 08:51:14 2025 -0700

    multiplexer: fix consume of too many bytes (#11499) (#11965)
    
    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.
    
    (cherry picked from commit 6774984a3f71f7473092d1af7ba99a004e8890d9)
    
    Co-authored-by: Brian Neradt <[email protected]>
---
 iocore/eventsystem/P_IOBuffer.h | 1 +
 plugins/multiplexer/fetcher.h   | 2 ++
 2 files changed, 3 insertions(+)

diff --git a/iocore/eventsystem/P_IOBuffer.h b/iocore/eventsystem/P_IOBuffer.h
index a3193b60b0..1448f9a0ca 100644
--- a/iocore/eventsystem/P_IOBuffer.h
+++ b/iocore/eventsystem/P_IOBuffer.h
@@ -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;
diff --git a/plugins/multiplexer/fetcher.h b/plugins/multiplexer/fetcher.h
index 45e892f2ba..fe23614264 100644
--- a/plugins/multiplexer/fetcher.h
+++ b/plugins/multiplexer/fetcher.h
@@ -211,6 +211,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) {

Reply via email to