Repository navigation
fix: bound InputMessenger non-protocol handlers - #3714
Merged
chenBright merged 4 commits intoNov 21, 2026
Merged
Conversation
Contributor
There was a problem hiding this comment.
Warning
Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.
Copilot review overview
2 open issues
What changed in this PR
Fixes an out-of-bounds write in InputMessenger::AddNonProtocolHandler() by enforcing the configured non-protocol handler capacity and adds a regression test to prevent future overflow.
Changes:
- Add a capacity bounds check before writing to
_handlers[index]and return-1on exhaustion. - Log an error when the non-protocol handler capacity is exceeded.
- Add a unit test covering capacity=1 behavior (second registration fails).
| File | Description |
|---|---|
src/brpc/input_messenger.cpp |
Prevents handler-array overflow by validating the next handler index against _capacity. |
test/brpc_input_messenger_unittest.cpp |
Adds regression coverage ensuring non-protocol handler registration respects capacity limits. |
Review effort: Lite
Copilot stopped reviewing on behalf of
chenBright due to an error
November 5, 2026 16:46
songgaoye
force-pushed
the
fix/input-messenger-handler-capacity
branch
from
November 8, 2026 03:16
836faa6 to
b830d0f
Compare
darion-yaphet
pushed a commit
to darion-yaphet/brpc
that referenced
this pull request
Nov 25, 2026
* fix: bound InputMessenger non-protocol handlers * Fix non-protocol handler capacity logging and test setup
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: resolve
Problem Summary:
InputMessenger::AddNonProtocolHandler()increments_max_indexand writesto
_handlers[index]without checking whetherindexis within_capacity.Registering more non-protocol handlers than the configured capacity therefore
writes past the handler array.
What is changed and the side effects?
Changed:
_capacitybefore accessing_handlers[index].-1and log an error when the non-protocol handler capacity isexhausted.
InputMessengerof capacity one.Side effects:
Performance effects:
Adds one bounds check during non-protocol handler registration, which is
setup-time work and not on the message-processing path.
Breaking backward compatibility:
Calls that previously overflowed the configured handler capacity now fail
cleanly with
-1.Check List: