summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--net/base/host_resolver_impl_unittest.cc7
-rw-r--r--net/base/host_resolver_proc.cc6
2 files changed, 7 insertions, 6 deletions
diff --git a/net/base/host_resolver_impl_unittest.cc b/net/base/host_resolver_impl_unittest.cc
index 3fbf041..11d7424 100644
--- a/net/base/host_resolver_impl_unittest.cc
+++ b/net/base/host_resolver_impl_unittest.cc
@@ -344,12 +344,7 @@ TEST_F(HostResolverImplTest, NumericIPv6Address) {
}
}
-// TODO(eroman): This test is disabled because it is bogus. It used to pass
-// solely because of a bug in the RuleBasedHostMapper -- (empty replacements
-// would map to a failure). However when using the actual host resolver
-// (getaddrinfo), this is not necessarily the case. On windows getaddrinfo("")
-// gives you the address of your machine.
-TEST_F(HostResolverImplTest, DISABLED_EmptyHost) {
+TEST_F(HostResolverImplTest, EmptyHost) {
scoped_refptr<RuleBasedHostResolverProc> resolver_proc =
new RuleBasedHostResolverProc(NULL);
resolver_proc->AllowDirectLookup("*");
diff --git a/net/base/host_resolver_proc.cc b/net/base/host_resolver_proc.cc
index 585a33e..8951646 100644
--- a/net/base/host_resolver_proc.cc
+++ b/net/base/host_resolver_proc.cc
@@ -125,6 +125,12 @@ ThreadLocalStorage::Slot DnsReloadTimer::tls_index_(base::LINKER_INITIALIZED);
#endif // defined(OS_LINUX)
int SystemHostResolverProc(const std::string& host, AddressList* addrlist) {
+ // The result of |getaddrinfo| for empty hosts is inconsistent across systems.
+ // On Windows it gives the default interface's address, whereas on Linux it
+ // gives an error. We will make it fail on all platforms for consistency.
+ if (host.empty())
+ return ERR_NAME_NOT_RESOLVED;
+
struct addrinfo* ai = NULL;
struct addrinfo hints = {0};
hints.ai_family = AF_UNSPEC;