Fix HPACK dynamic table size update recursive decoding#3343
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes HPACK decoding behavior for Dynamic Table Size Update entries by removing recursive re-entry into the decoder, preventing deep call stacks when many consecutive updates appear, and ensuring the returned “bytes consumed” count includes any leading table size updates.
Changes:
- Replace recursive handling of consecutive Dynamic Table Size Update entries with an iterative decode loop.
- Preserve total consumed byte count when size updates precede a decoded header field.
- Add regression tests covering long update sequences and update-before-header decoding.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
src/brpc/details/hpack.cpp |
Makes HPACK decode skip consecutive dynamic table size updates iteratively and correctly accumulate consumed bytes before returning a decoded header. |
test/brpc_hpack_unittest.cpp |
Adds regression tests to prevent stack-overflow regressions and to verify consumed-byte accounting when updates precede a header. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What problem does this PR solve?
Issue Number: null
Problem Summary:
HPACK decoding handled Dynamic Table Size Update entries by recursively calling
the decoder again. A header block containing many consecutive table size updates
could therefore use a large amount of call stack before reaching a real header
field or the end of input.
What is changed and the side effects?
Changed:
decoded header field.
decoding.
Side effects:
Performance effects: avoids recursive call overhead for consecutive table
size updates.
Breaking backward compatibility: none.
Check List: