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

Unified Diff: net/dns/dns_config_service_posix_unittest.cc

Issue 10546081: [net/dns] If the only name server is 0.0.0.0:53 assume DnsConfig is invalid. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Reject when any nameserver is 0.0.0.0 Created 8 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
« no previous file with comments | « net/dns/dns_config_service_posix.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/dns/dns_config_service_posix_unittest.cc
diff --git a/net/dns/dns_config_service_posix_unittest.cc b/net/dns/dns_config_service_posix_unittest.cc
index 227128097b4c71d139e18cde3107d3be44b3285b..e1e23380f68cc72494679e22cc593911bfc96650 100644
--- a/net/dns/dns_config_service_posix_unittest.cc
+++ b/net/dns/dns_config_service_posix_unittest.cc
@@ -122,5 +122,29 @@ TEST(DnsConfigServicePosixTest, ConvertResStateToDnsConfig) {
EXPECT_TRUE(expected_config.EqualsIgnoreHosts(config));
}
+TEST(DnsConfigServicePosixTest, RejectEmptyNameserver) {
+ struct __res_state res = {};
+ res.options = RES_INIT;
+ const char kDnsrch[] = "chromium.org";
+ memcpy(res.defdname, kDnsrch, sizeof(kDnsrch));
+ res.dnsrch[0] = res.defdname;
+
+ struct sockaddr_in sa = {};
+ sa.sin_family = AF_INET;
+ sa.sin_port = base::HostToNet16(NS_DEFAULTPORT);
+ sa.sin_addr.s_addr = INADDR_ANY;
+ res.nsaddr_list[0] = sa;
+ sa.sin_addr.s_addr = 0xCAFE1337;
+ res.nsaddr_list[1] = sa;
+ res.nscount = 2;
+
+ DnsConfig config;
+ EXPECT_FALSE(internal::ConvertResStateToDnsConfig(res, &config));
+
+ sa.sin_addr.s_addr = 0xDEADBEEF;
+ res.nsaddr_list[0] = sa;
+ EXPECT_TRUE(internal::ConvertResStateToDnsConfig(res, &config));
+}
+
} // namespace
} // namespace net
« no previous file with comments | « net/dns/dns_config_service_posix.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698