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

Unified Diff: net/dns/host_resolver_impl_unittest.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/dns/host_resolver_impl.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/dns/host_resolver_impl_unittest.cc
diff --git a/net/dns/host_resolver_impl_unittest.cc b/net/dns/host_resolver_impl_unittest.cc
index 7a46a1c4dc4e3cfc1998858a5fb8bc75bd9b0fe7..783d482906f99f95158e6c8b504ad852239a4082 100644
--- a/net/dns/host_resolver_impl_unittest.cc
+++ b/net/dns/host_resolver_impl_unittest.cc
@@ -1319,6 +1319,53 @@ TEST_F(HostResolverImplTest, MultipleAttempts) {
EXPECT_EQ(resolver_proc->resolved_attempt_number(), kAttemptNumberToResolve);
}
+// If a host resolves to a list that includes 127.0.53.53, this is treated as
+// an error. 127.0.53.53 is a localhost address, however it has been given a
+// special significance by ICANN to help surfance name collision resulting from
+// the new gTLDs.
+TEST_F(HostResolverImplTest, NameCollision127_0_53_53) {
+ proc_->AddRuleForAllFamilies("single", "127.0.53.53");
+ proc_->AddRuleForAllFamilies("multiple", "127.0.0.1,127.0.53.53");
+ proc_->AddRuleForAllFamilies("ipv6", "::127.0.53.53");
+ proc_->AddRuleForAllFamilies("not_reserved1", "53.53.0.127");
+ proc_->AddRuleForAllFamilies("not_reserved2", "127.0.53.54");
+ proc_->AddRuleForAllFamilies("not_reserved3", "10.0.53.53");
+ proc_->SignalMultiple(6u);
+
+ Request* request;
+
+ request = CreateRequest("single");
+ EXPECT_EQ(ERR_IO_PENDING, request->Resolve());
+ EXPECT_EQ(ERR_ICANN_NAME_COLLISION, request->WaitForResult());
+
+ request = CreateRequest("multiple");
+ EXPECT_EQ(ERR_IO_PENDING, request->Resolve());
+ EXPECT_EQ(ERR_ICANN_NAME_COLLISION, request->WaitForResult());
+
+ // Resolving an IP literal of 127.0.53.53 however is allowed.
+ EXPECT_EQ(OK, CreateRequest("127.0.53.53")->Resolve());
+
+ // Moreover the address should not be recognized when embedded in an IPv6
+ // address.
+ request = CreateRequest("ipv6");
+ EXPECT_EQ(ERR_IO_PENDING, request->Resolve());
+ EXPECT_EQ(OK, request->WaitForResult());
+
+ // Try some other IPs which are similar, but NOT an exact match on
+ // 127.0.53.53.
+ request = CreateRequest("not_reserved1");
+ EXPECT_EQ(ERR_IO_PENDING, request->Resolve());
+ EXPECT_EQ(OK, request->WaitForResult());
+
+ request = CreateRequest("not_reserved2");
+ EXPECT_EQ(ERR_IO_PENDING, request->Resolve());
+ EXPECT_EQ(OK, request->WaitForResult());
+
+ request = CreateRequest("not_reserved3");
+ EXPECT_EQ(ERR_IO_PENDING, request->Resolve());
+ EXPECT_EQ(OK, request->WaitForResult());
+}
+
DnsConfig CreateValidDnsConfig() {
IPAddressNumber dns_ip;
bool rv = ParseIPLiteralToNumber("192.168.1.0", &dns_ip);
« no previous file with comments | « net/dns/host_resolver_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698