Skip to content

Fix DNS resolver accepting an A record shorter than its RDLENGTH - #107

Merged
Watson1978 merged 1 commit into
socketry:mainfrom
Watson1978:fix-dns-truncated-rdata
Sep 5, 2026
Merged

Fix DNS resolver accepting an A record shorter than its RDLENGTH#107
Watson1978 merged 1 commit into
socketry:mainfrom
Watson1978:fix-dns-truncated-rdata

Conversation

@Watson1978

@Watson1978 Watson1978 commented Sep 5, 2026

Copy link
Copy Markdown
Collaborator

DNSResolver#response_address trusted the RDLENGTH of each answer record. A response whose RDATA is shorter than the declared length was unpacked into a bogus address such as "...", which reached TCPConnectResolver#on_success, where Socket.sockaddr_in raised SocketError. That exception is not rescued there, so a malformed response from the nameserver stopped the event loop.

This change returns nil when the datagram holds fewer bytes than the record declares, so such a response takes the existing on_failure path like any other unresolvable answer. A regression spec covers the truncated case.

🤖 Generated with Claude Code

response_address trusted the RDLENGTH of each answer record and
unpacked a truncated RDATA into a bogus address such as "...". That
string reached TCPConnectResolver#on_success, where Socket.sockaddr_in
raised SocketError, and the exception escaped the event loop.

Return nil when the datagram holds fewer bytes than the record
declares, so a malformed response takes the existing on_failure path.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@Watson1978
Watson1978 merged commit 898b7a6 into socketry:main Sep 5, 2026
14 checks passed
@Watson1978
Watson1978 deleted the fix-dns-truncated-rdata branch September 5, 2026 09:48
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.

1 participant