Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug fix for use-after-close connection in AXFR #523

Merged
merged 2 commits into from
Feb 26, 2025

Conversation

phillip-stephens
Copy link
Contributor

Closes #522

@smeinecke Thank you for the thorough bug report, made it a lot easier to debug.

On inspection with git bisect this was caused by the CLI + Library refactor (c192044). In the old code, there was a dns.Transfer in every RoutineLookupFactory, importantly, per-thread.

In the new code, there was one in the AXFRModule which is shared by multiple threads. The first lookup would have opened a connection and then closed it. The second lookup has logic that if the connection is nil, it'll open a new one. However if it is non-nil (but closed), it'll attempt to write. This resulted in the error.

The fix is to have a connection per Lookup(). Needed to use an interface factory so we can mock this in the unit tests.

Testing

echo -e "zonetransfer.me,81.4.108.41\nzonetransfer.me,5.196.105.10" | ./zdns AXFR
echo -e "zonetransfer.me,81.4.108.41\nzonetransfer.me,5.196.105.10" | ./zdns AXFR --threads=1

@phillip-stephens phillip-stephens requested a review from a team as a code owner February 26, 2025 16:13
@zakird zakird merged commit d4b8b3f into main Feb 26, 2025
4 checks passed
@zakird zakird deleted the phillip/522-axfr-bug-conn-reuse branch February 26, 2025 16:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug] AXFR fails on 2nd request
2 participants