Repository navigation
fix: reject malformed inner-batch message lengths - #11488
Open
huier5635-cmd wants to merge 1 commit into
Open
huier5635-cmd wants to merge 1 commit into
huier5635-cmd wants to merge 1 commit into
Conversation
Validate record boundaries before advancing the decoder, return MESSAGE_ILLEGAL for invalid or empty inner batches, and cover stalled and valid broker paths. Signed-off-by: huier <huier5635@gmail.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #11488 +/- ##
=============================================
+ Coverage 49.76% 49.79% +0.03%
- Complexity 14381 14389 +8
=============================================
Files 1391 1391
Lines 103350 103361 +11
Branches 13518 13521 +3
=============================================
+ Hits 51428 51469 +41
+ Misses 45711 45672 -39
- Partials 6211 6220 +9 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
Which Issue(s) This PR Fixes
No existing issue is linked; the regression tests below reproduce the defect against
develop.Brief Description
MessageDecoder.countInnerMsgNumadvances the buffer by the encoded record size. A zero size leaves the position unchanged and the loop never terminates. The broker calls this method when processing an inner batch for a BatchCQ topic.Validate that a size field is present, the record includes the 22-byte encoded header, and the record fits within the remaining buffer before advancing and counting it. Return
MESSAGE_ILLEGALfor malformed or empty inner batches before invoking storage.Regression tests cover stalled and invalid record lengths, a malformed following record, valid encoded batches with direct/read-only buffers and nonzero positions, and the actual broker rejection/storage paths. Valid batches retain their body, message count, flags, and successful response.
How Did You Test This Change?
Validated against Apache commit
38a7ca0d23a3e2d4339f9a2bf6e78cf541eed9e3, including recursive submodules, on Ubuntu 24.04 with Corretto JDK 8 and Maven 3.10.0. Maven's default Checkstyle and JaCoCo configuration remained enabled.mvn -B -ntp -pl broker -am -DskipTests install.mvn -B -ntp -pl broker -am -Dtest=MessageDecoderTest,SendMessageProcessorTest -Dsurefire.failIfNoSpecifiedTests=false testpassed all 30 tests in the two related classes, with no skips.mvn -B -ntp -pl common testpassed all 271 tests, with no skips.git diff --check, and verification of the four final source-file hashes passed.Reproducible validation run and raw XML/log artifact. The validation workflow checks out and tests the Apache sources; it is not part of this PR. The full broker suite and a live broker cluster were not run.