fix(udp): short-circuit UDP file-info handler when client is banned - #192
Merged
Merged
Conversation
ClientUDPSocket.cpp:194 calls CheckForAggressive() on incoming file-info packets but doesn't check IsBanned() after, unlike the TCP file-request path at ClientTCPSocket.cpp:539 (and the TCP OP_AICHREQUEST path added in amule-project#186). CheckForAggressive can call Ban() when m_Aggressiveness >= 10, but the UDP handler then falls through and keeps processing the request anyway -- AddAskedCount(), SetUDPPort(), SetLastUpRequest(), ProcessExtendedInfo(), etc. A freshly-banned client could keep the seeder doing work on each UDP file-info packet it sends. Small leak, same shape as the TCP gap that amule-project#186 closed. Mirror the TCP guard: break out of the dispatch case if IsBanned() returns true. Reported by @danim7 in amule-org#186 (comment) (point 3).
4 tasks
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.
Summary
Follow-up to #186, addressing point 3 of @danim7's post-merge review.
ClientUDPSocket.cpp:194callsCheckForAggressive()on incoming UDP file-info packets but doesn't short-circuit onIsBanned()after, unlike the TCP file-request path atClientTCPSocket.cpp:539(and the TCPOP_AICHREQUESTpath added in #186).CheckForAggressivecan callBan()whenm_Aggressiveness >= 10, but the UDP handler then falls through and keeps processing the request anyway —AddAskedCount(),SetUDPPort(),SetLastUpRequest(),ProcessExtendedInfo(), and on through the rest of the case.A freshly-banned client could keep the seeder doing work on each UDP file-info packet it sends. Small leak, same shape as the TCP gap that #186 closed.
What this changes
Mirror the TCP guard:
breakout of the dispatch case ifIsBanned()returnstrueimmediately afterCheckForAggressive().Verification
This is the smallest possible diff that brings the UDP file-info handler in line with the rest of the aggressive-check paths in the codebase.