Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(320)

Unified Diff: net/dns/host_resolver_impl.cc

Issue 1177933002: Resolve RFC 6761 localhost names to loopback (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: net/dns/host_resolver_impl.cc
diff --git a/net/dns/host_resolver_impl.cc b/net/dns/host_resolver_impl.cc
index 970ec1f457ade5ba90b1b2ac6224f57e782c0271..7d00256d132b08b4b0f2e518be4ce6438156a6c3 100644
--- a/net/dns/host_resolver_impl.cc
+++ b/net/dns/host_resolver_impl.cc
@@ -1997,6 +1997,17 @@ int HostResolverImpl::ResolveHelper(const Key& key,
source_net_log.AddEvent(NetLog::TYPE_HOST_RESOLVER_IMPL_HOSTS_HIT);
return OK;
}
+
+ // Per RFC 6761 section 6.3, resolve localhost to loopback without
+ // sending it out on the network.
+ if (IsLocalhost(base::StringToLowerASCII(key.hostname))) {
Ryan Sleevi 2015/06/11 00:34:03 BUG: Should IsLocalhost be doing the case conversi
estark 2015/06/11 02:35:32 Done.
+ addresses->clear();
+ IPAddressNumber ip_address;
+ ParseIPLiteralToNumber("127.0.0.1", &ip_address);
Ryan Sleevi 2015/06/11 00:34:03 BUG 1: This isn't correct for localhost6 (which sh
estark 2015/06/11 02:35:32 Done by factoring out the hostname check of IsLoca
+ addresses->push_back(IPEndPoint(ip_address, info.port()));
+ return OK;
+ }
+
return ERR_DNS_CACHE_MISS;
}

Powered by Google App Engine
This is Rietveld 408576698