Skip to content

Commit 084040d

Browse files
bneradtbneradt
andauthored
Guard HTTP/2 frame sequence lookahead (#364)
H2Session::write() pops the current frame from the stream frame sequence and then immediately looks at the next entry to decide which flags to set. When the current frame is the last queued frame, that unconditional front() call reads past the end of the deque and aborts proxy-verifier with a std::deque::front() assertion. Treat an empty post-pop frame sequence as having no next frame by using H2Frame::INVALID for the lookahead value. That preserves the existing flag selection logic while avoiding the invalid deque access on the final frame. Co-authored-by: bneradt <bneradt@yahooinc.com>
1 parent ca50667 commit 084040d

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

src/core/http2.cc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1505,7 +1505,9 @@ H2Session::write(HttpHeader const &hdr)
15051505
while (!stream_state->_h2_frame_sequence.empty()) {
15061506
auto curr_frame = stream_state->_h2_frame_sequence.front();
15071507
stream_state->_h2_frame_sequence.pop_front();
1508-
auto next_frame = stream_state->_h2_frame_sequence.front();
1508+
auto const next_frame = stream_state->_h2_frame_sequence.empty() ?
1509+
H2Frame::INVALID :
1510+
stream_state->_h2_frame_sequence.front();
15091511

15101512
uint8_t flags = 0;
15111513

0 commit comments

Comments
 (0)