fix: reject oversized telnet payload before header copy - #16404
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## 3.3 #16404 +/- ##
=========================================
Coverage 60.87% 60.88%
- Complexity 11766 11769 +3
=========================================
Files 1953 1953
Lines 89273 89278 +5
Branches 13473 13477 +4
=========================================
+ Hits 54346 54354 +8
+ Misses 29333 29327 -6
- Partials 5594 5597 +3
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
It may be sufficient to only handle cases greater than 1 |
I don't think this change provides any meaningful behavioral benefit. When readable == 1, checkPayload is effectively a no-op because the smallest positive payload limit is 1, and the check only rejects size > payload. The current condition is correct and keeps the zero-readable case explicit, so I'd prefer to leave it as is. |
When the server-side
ExchangeCodecreceives 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?
checkPayload(channel, readable)for non-magic server-side input.new byte[]andbuffer.readBytes(...).Tests
Added a regression test to verify that:
ExceedPayloadLimitException.Executed:
mvn -pl dubbo-remoting/dubbo-remoting-api \ -DskipITs \ -Dcheckstyle.skip \ -Drat.skip=true \ -Dtest=ExchangeCodecTest \ test