net: NS lookups fail unexpectedly on non-existing domains if resolv.conf
contains search .
#54124
Labels
FrozenDueToAge
help wanted
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone
Description
If performing an NS lookup while having a resolv.conf containing a
search
option where the last value is a single.
, thenet.LookupNS
function fails to perform the lookup, because the search line parser can't figure out what to do with a single dot, and simple appends it to the address it's trying to look up, resulting innet.Lookup
looking updomain.com..
.As far as I can tell, while somewhat nonsensical,
search .
should be perfectly legal to have in resolv.conf, and indeed system resolvers don't seem to mind it.The specific
search
line is put there bysystemd-resolved
, it seems. I can't tell you exactly why, but I can tell you that I get no search domains from the DHCP server.What version of Go are you using?
1.16.15, 1.17.9, 1.18.1, 1.18.4
Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
search .
in/etc/resolv.conf
(or anysearch
line where the last item is a lone.
)What did you expect to see?
lookup non-existing-domain.com on 127.0.0.53:53: no such host
What did you see instead?
lookup non-existing-domain.com on 127.0.0.53:53: cannot marshal DNS message
Suggested solution
Two trivial ways solve this, none of which are particularly pretty. But since my knowledge of the codebase is limited, there are likely better ways, so for illustrative purposes, here goes:
src/net/dnsclient_unix.go:481
, addsrc/net/dnsconfig_unix.go:89
, change the iteration toI do think this is probably a corner case, but since this is being thrust into resolv.conf by a widely used local resolver (and I'm not entirely sure it's not their fault, and it might well be), I think it might warrant if nothing else a cursory look.
The text was updated successfully, but these errors were encountered: