You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[Android] Fall back to 'localhost' when *.localhost resolves to only non-loopback addresses
Dns falls back to resolving plain 'localhost' when the OS resolver fails or returns zero addresses for a '*.localhost' subdomain (RFC 6761 Section 6.3). However, on Android the bionic getaddrinfo returns non-loopback addresses (link-local fe80::* and globally-routable IPv6) for '*.localhost', bypassing the fallback and causing Dns.GetHostAddresses("foo.localhost.") to return non-loopback addresses. This was caused by the fallback condition only triggering on empty or failed OS responses; it is now extended to also trigger when the OS returns only non-loopback addresses, in both the sync and async paths.
Fixes#127965.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
// RFC 6761 Section 6.3: If localhost subdomain returns empty addresses, fall back to plain "localhost".
528
-
if(NetEventSource.Log.IsEnabled())NetEventSource.Info(hostName,"RFC 6761: Localhost subdomain returned empty, falling back to 'localhost'");
552
+
// RFC 6761 Section 6.3: If localhost subdomain returns empty addresses, or only
553
+
// non-loopback addresses (e.g. Android bionic returns globally-routable IPv6 for
554
+
// "*.localhost"), fall back to plain "localhost".
555
+
if(NetEventSource.Log.IsEnabled())NetEventSource.Info(hostName,"RFC 6761: Localhost subdomain returned no loopback addresses, falling back to 'localhost'");
if(NetEventSource.Log.IsEnabled())NetEventSource.Info(hostName,"RFC 6761: Localhost subdomain returned empty, falling back to 'localhost'");
824
+
if(NetEventSource.Log.IsEnabled())NetEventSource.Info(hostName,"RFC 6761: Localhost subdomain returned no loopback addresses, falling back to 'localhost'");
if(NetEventSource.Log.IsEnabled())NetEventSource.Info(hostName,"RFC 6761: Localhost subdomain returned empty, falling back to 'localhost'");
835
+
if(NetEventSource.Log.IsEnabled())NetEventSource.Info(hostName,"RFC 6761: Localhost subdomain returned no loopback addresses, falling back to 'localhost'");
0 commit comments