Reject empty MySQL response packets - #3536
Merged
Merged
Conversation
Validate packet payload lengths before reading the response type byte. This prevents an empty packet from borrowing the first byte of a following packet during response parsing.
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No unresolved review issues were identified, and regression coverage was added.
Pull request overview
This PR hardens MySQL response parsing by rejecting zero-length packets before reading their response type.
Changes:
- Validates empty packets, including after fast-auth markers.
- Adds regression tests for standalone, trailing, and fast-auth cases.
File summaries
| File | Description |
|---|---|
test/brpc_mysql_reply_parse_unittest.cpp |
Tests malformed empty-packet scenarios. |
src/brpc/policy/mysql/mysql_reply.cpp |
Rejects zero-length packets during response parsing. |
Review details
- Files reviewed: 2/2 changed files
- Comments generated: 0
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Contributor
|
LGTM |
Member
Author
|
The two flaky unit tests are not related to this change, and I will fix them separately. |
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:
Problem Summary:
The MySQL response parser reads the response type byte without first
rejecting packets whose declared payload length is zero. When another packet
follows, the parser may treat that packet's first byte as the empty packet's
type.
What is changed and the side effects?
Changed:
Side effects:
type.
rejected instead of being interpreted using following bytes.
Check List: