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

Unified Diff: net/dns/host_resolver_impl.cc

Issue 1035803003: Fail DNS resolution if the result contains 127.0.53.53. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add 3 more test cases Created 5 years, 9 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
« no previous file with comments | « net/base/net_error_list.h ('k') | net/dns/host_resolver_impl_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/dns/host_resolver_impl.cc
diff --git a/net/dns/host_resolver_impl.cc b/net/dns/host_resolver_impl.cc
index 6c0a154971a4fe2a4386051bef361ac7188046fc..c8b37f73b30011007d989d4ca18493357d1c7332 100644
--- a/net/dns/host_resolver_impl.cc
+++ b/net/dns/host_resolver_impl.cc
@@ -144,6 +144,17 @@ enum DnsResolveStatus {
RESOLVE_STATUS_MAX
};
+// ICANN uses this localhost address to indicate a name collision.
+//
+// The policy in Chromium is to fail host resolving if it resolves to
+// this special address.
+//
+// Not however that IP literals are exempt from this policy, so it is still
+// possible to navigate to http://127.0.53.53/ directly.
+//
+// For more details: https://www.icann.org/news/announcement-2-2014-08-01-en
+const unsigned char kIcanNameCollisionIp[] = {127, 0, 53, 53};
+
void UmaAsyncDnsResolveStatus(DnsResolveStatus result) {
UMA_HISTOGRAM_ENUMERATION("AsyncDNS.ResolveStatus",
result,
@@ -663,6 +674,17 @@ class HostResolverImpl::ProcTask
&results,
&os_error);
+ // Fail the resolution if the result contains 127.0.53.53. See the comment
+ // block of kIcanNameCollisionIp for details on why.
+ for (const auto& it : results) {
+ const IPAddressNumber& cur = it.address();
+ if (cur.size() == arraysize(kIcanNameCollisionIp) &&
+ 0 == memcmp(&cur.front(), kIcanNameCollisionIp, cur.size())) {
+ error = ERR_ICANN_NAME_COLLISION;
+ break;
+ }
+ }
+
origin_loop_->PostTask(
FROM_HERE,
base::Bind(&ProcTask::OnLookupComplete, this, results, start_time,
« no previous file with comments | « net/base/net_error_list.h ('k') | net/dns/host_resolver_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698