Repository navigation
Conversation
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Deterministic error and status information is not propagated for oversized bucket and credential failures, leaving callers with empty messages and potentially uninitialized status codes.
2 open issues
What changed in this PR
This PR hardens Couchbase binary request serialization by rejecting inputs that exceed the protocol's fixed-width key and body length fields before malformed frames can be produced.
Changes:
- Added shared validation for request and SASL authentication lengths.
- Applied validation across request builders, collection-aware operations, authentication, and high-level requests.
- Added boundary and regression tests for oversized inputs and rejection-state preservation.
| File | Description |
|---|---|
| test/brpc_couchbase_unittest.cpp | Adds protocol-boundary and oversized-request regression tests, including buffer and pipeline preservation checks. |
| src/brpc/policy/couchbase_protocol.h | Defines shared length-validation helpers for Couchbase requests and SASL payloads. |
| src/brpc/policy/couchbase_authenticator.cpp | Rejects oversized SASL authentication payloads before serialization. |
| src/brpc/couchbase.cpp | Integrates length validation across bucket, key, value, body, collection, counter, authentication, and high-level request paths. |
Review effort: Lite
Comment on lines
+461
to
+463
| if (!ValidCouchbaseRequestLengths(bucket_name.size(), 0, 0, 0)) { | ||
| return false; | ||
| } |
Comment on lines
+575
to
+577
| if (!policy::ValidCouchbaseAuthLengths(username.size(), password.size())) { | ||
| return false; | ||
| } |
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:
Couchbase request builders can narrow key, bucket, and body lengths to the
protocol's 16-bit and 32-bit fields while appending the full input. Oversized
inputs can produce malformed frames and desynchronize the connection.
What is changed and the side effects?
Changed:
serialization.
metadata.
buffer and pipeline count after rejection.
Side effects:
Performance effects: Adds constant-time length checks before request
construction. The impact has not been benchmarked.
Breaking backward compatibility: Requests exceeding protocol length limits
now fail instead of producing malformed frames.
Check List:
brpc_couchbase_unittestand passed all 8CouchbaseUnitTesttests.