-
Notifications
You must be signed in to change notification settings - Fork 493
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
p2p: fix infinite loop in dnsaddr resolution #5926
p2p: fix infinite loop in dnsaddr resolution #5926
Conversation
mockController{}, | ||
func(dnsaddr multiaddr.Multiaddr, entries []multiaddr.Multiaddr) error { return nil }, | ||
) | ||
return true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ideally this would check the error returned by Iterate
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why? I want to check no infinite loops and not resolution errors
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You made the decision to return an error when max hops are reached. In my view, it only makes sense to test that return value here, rather than ignoring it
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## feature/p2p #5926 +/- ##
===============================================
+ Coverage 55.98% 55.99% +0.01%
===============================================
Files 482 482
Lines 68057 68062 +5
===============================================
+ Hits 38103 38114 +11
+ Misses 27347 27343 -4
+ Partials 2607 2605 -2 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I left a test suggestion, but it's not serious enough to be a blocker
mockController{}, | ||
func(dnsaddr multiaddr.Multiaddr, entries []multiaddr.Multiaddr) error { return nil }, | ||
) | ||
return true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You made the decision to return an error when max hops are reached. In my view, it only makes sense to test that return value here, rather than ignoring it
@@ -35,8 +35,14 @@ func Iterate(initial multiaddr.Multiaddr, controller ResolveController, f func(d | |||
if resolver == nil { | |||
return errors.New("passed controller has no resolvers Iterate") | |||
} | |||
const maxHops = 100 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why 100 - i.e. this feels more like 10 is sufficient..?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do not know what is actual max limit
Summary
dnsaddr.Iterate()
is not tolerate to cycles. Added max attempts to prevent infinite looping.Test Plan
Added a unit test.