{{ message }}
Repository navigation
fix popCollectionId over-consuming the couchbase response body - #3614
Open
sahvx655-wq wants to merge 1 commit into
Open
sahvx655-wq wants to merge 1 commit into
sahvx655-wq wants to merge 1 commit into
Conversation
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: N/A
Problem Summary:
CouchbaseOperations::CouchbaseResponse::popCollectionIdinsrc/brpc/couchbase.cppparses aCB_COLLECTIONS_GET_CIDresponse whosetotal_body_lengthalready counts the 12-byte extras (8-byte manifest id plus 4-byte collection id). On the success path it pops the 24-byte header, then pops 8 bytes for the manifest id, 4 bytes for the collection id, and then popstotal_body_lengthagain. Those 12 extras bytes are part oftotal_body_length, so the handler consumes 12 bytes too many and reads into the next pipelined response, desyncing every following response on the connection. The header fields come straight from the (untrusted) server peer, and a response withextras_length >= 12buttotal_body_length < 12reaches the fixed 8+4-byte reads with no lower bound.What is changed and the side effects?
Changed:
Reject the response when
total_body_length < 12next to the existingextras_length < 12check, and pop onlytotal_body_length - 12remaining body bytes after the extras so the handler consumes exactly one message. The siblingpop*handlers already size their value against the body, so only this one was affected.CouchbaseUnitTest.CollectionIdSuccessConsumesExactBodyfeeds a valid GET_CID response followed by a second response and checks the second one is left intact: it fails on master (12 bytes of the next response are eaten, leaving 52 instead of 64) and passes with the fix.Side effects:
Performance effects: none
Breaking backward compatibility: no