Skip to content

Resolv: continue the search list on NODATA replies - #162

Open
TheRealAlexxx wants to merge 1 commit into
ruby:masterfrom
TheRealAlexxx:bug-18842
Open

TheRealAlexxx wants to merge 1 commit into
ruby:masterfrom
TheRealAlexxx:bug-18842

Conversation

@TheRealAlexxx

Copy link
Copy Markdown

Resolv: continue the search list on NODATA replies

Fixes [Bug #18842].

When a name is resolved through the search list, Resolv::DNS#fetch_resource stops at the first candidate whose reply has rcode NoError, even when the answer section is empty (a NODATA reply: the name exists, but has no records of the requested type). The remaining search domains, and the name as given, are never tried, so getaddress/getresources report no information even though a later search domain holds the record.

NXDomain replies already continue to the next candidate via Config#resolv. This change treats NODATA the same way: a NoError reply with an empty answer section raises a new Config::NODATA, which Config#resolv rescues alongside NXDomain before moving on to the next candidate. A NODATA reply for the final candidate is swallowed as before, so the all-NODATA outcome is unchanged.

The new test runs a stub DNS server that answers NODATA for the first two search-list candidates and an A record for the third; getaddress now returns the third candidate's address instead of raising ResolvError.

Fixes [Bug #18842].

When a name is resolved through the search list, `Resolv::DNS#fetch_resource` stops at the first candidate whose reply has rcode NoError, even when the answer section is empty (a NODATA reply: the name exists, but has no records of the requested type). The remaining search domains, and the name as given, are never tried, so `getaddress`/`getresources` report no information even though a later search domain holds the record.

NXDomain replies already continue to the next candidate via `Config#resolv`. This change treats NODATA the same way: a NoError reply with an empty answer section raises a new `Config::NODATA`, which `Config#resolv` rescues alongside `NXDomain` before moving on to the next candidate. A NODATA reply for the final candidate is swallowed as before, so the all-NODATA outcome is unchanged.

The new test runs a stub DNS server that answers NODATA for the first two search-list candidates and an A record for the third; `getaddress` now returns the third candidate's address instead of raising `ResolvError`.

This branch has not been deployed

No deployments
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