wwbmmm opened a new pull request, #3449:
URL: https://github.com/apache/brpc/pull/3449

   ### What problem does this PR solve?
   
   Issue Number: null
   
   Problem Summary:
   
   The SOFA PBRPC parser (`ParseSofaMessage`) enforces `FLAGS_max_body_size`
   only on the frame's `body_size` field. The `meta_size` field, and
   therefore the whole frame size, is not bounded. A peer can send a frame
   with a large `meta_size` and `body_size = 0`, which passes the current
   check, so the connection keeps reading and buffering the declared frame
   until the metadata is finally parsed (and rejected). This makes the
   configured per-message limit ineffective and can consume much more memory
   than expected.
   
   ### What is changed and the side effects?
   
   Changed:
   
   - In `ParseSofaMessage`, reject frames whose `meta_size` exceeds
     `FLAGS_max_body_size`, in addition to the existing `body_size` check.
   - Add unit tests in `test/brpc_sofa_pbrpc_protocol_unittest.cpp` covering
     an oversized body and an oversized metadata block.
   
   Side effects:
   
   - Performance effects: none.
   - Breaking backward compatibility: SOFA frames whose metadata exceeds
     `max_body_size` (previously buffered and then rejected at protobuf
     parsing time) are now rejected earlier with a "too big data" error and
     the connection is closed.
   
   ---
   
   ### Check List:
   
   - Please make sure your changes are compilable.
   - When providing us with a new feature, it is best to add related tests.
   - Please follow [Contributor Covenant Code of 
Conduct](https://github.com/apache/brpc/blob/master/CODE_OF_CONDUCT.md).
   
   Tests run:
   
   - `test/brpc_sofa_pbrpc_protocol_unittest` (all cases passed)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to