Skip to content

Fix HPACK dynamic table size update recursive decoding#3343

Merged
wwbmmm merged 1 commit into
apache:masterfrom
wwbmmm:fix-hpack-recursive-decoding
Jun 14, 2026
Merged

Fix HPACK dynamic table size update recursive decoding#3343
wwbmmm merged 1 commit into
apache:masterfrom
wwbmmm:fix-hpack-recursive-decoding

Conversation

@wwbmmm

@wwbmmm wwbmmm commented Jun 14, 2026

Copy link
Copy Markdown
Contributor

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:

  • Decode consecutive Dynamic Table Size Update entries iteratively.
  • Preserve the total consumed byte count when table size updates precede a
    decoded header field.
  • Add HPACK regression tests for long update sequences and update-before-header
    decoding.

Side effects:

  • Performance effects: avoids recursive call overhead for consecutive table
    size updates.

  • Breaking backward compatibility: none.


Check List:

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@chenBright chenBright left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@wwbmmm wwbmmm merged commit 1725896 into apache:master Jun 14, 2026
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants