From 4154786bb3f8655d0a9cb6dee37df90ff735c8e7 Mon Sep 17 00:00:00 2001 From: "ericroman@google.com" Date: Mon, 17 Aug 2009 20:47:02 +0000 Subject: Undisable HostResolverImplTest.EmptyHost, by making empty host fail to resolve. Review URL: http://codereview.chromium.org/164546 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@23576 0039d316-1c4b-4281-b951-d872f2087c98 --- net/base/host_resolver_impl_unittest.cc | 7 +------ net/base/host_resolver_proc.cc | 6 ++++++ 2 files changed, 7 insertions(+), 6 deletions(-) (limited to 'net/base') 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 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; -- cgit v1.1