RainYuY opened a new pull request, #16404:
URL: https://github.com/apache/dubbo/pull/16404

   When the server-side `ExchangeCodec` receives non-Dubbo input, it currently 
allocates and copies the entire readable buffer before the Telnet payload limit 
is checked. An oversized input can therefore cause an unnecessary large 
byte-array allocation and copy.
   
   This change validates the readable payload size in `ExchangeCodec.decode()` 
before allocating the header buffer for non-magic server-side input.
   
   ### What has changed?
   
   - Added an early `checkPayload(channel, readable)` for non-magic server-side 
input.
   - The validation is performed before `new byte[]` and 
`buffer.readBytes(...)`.
   - Inputs with the Dubbo magic header continue through the existing Dubbo 
header/body decoding path.
   - Client-side decoding and Telnet command parsing behavior remain unchanged.
   - No cross-packet scan state or decoder structure was introduced.
   
   ### Tests
   
   Added a regression test to verify that:
   
   - An oversized non-magic input throws `ExceedPayloadLimitException`.
   - The input buffer is not consumed when validation fails.
   
   Executed:
   
   ```bash
   mvn -pl dubbo-remoting/dubbo-remoting-api \
     -DskipITs \
     -Dcheckstyle.skip \
     -Drat.skip=true \
     -Dtest=ExchangeCodecTest \
     test


-- 
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