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

Unified Diff: net/dns/dns_config_service_posix.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 | « no previous file | net/dns/dns_config_service_posix_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/dns/dns_config_service_posix.cc
diff --git a/net/dns/dns_config_service_posix.cc b/net/dns/dns_config_service_posix.cc
index 40c710abf9e29315953013c62cf83cff5ab51587..5daaf69aac7b1c1357d08ce7b099a83eac75c56f 100644
--- a/net/dns/dns_config_service_posix.cc
+++ b/net/dns/dns_config_service_posix.cc
@@ -14,6 +14,7 @@
#include "net/base/ip_endpoint.h"
#include "net/base/net_util.h"
#include "net/dns/dns_hosts.h"
+#include "net/dns/dns_protocol.h"
#include "net/dns/serial_worker.h"
namespace net {
@@ -201,8 +202,8 @@ bool ConvertResStateToDnsConfig(const struct __res_state& res,
for (int i = 0; i < res.nscount; ++i) {
IPEndPoint ipe;
if (!ipe.FromSockAddr(
- reinterpret_cast<const struct sockaddr*>(&res.nsaddr_list[i]),
- sizeof res.nsaddr_list[i])) {
+ reinterpret_cast<const struct sockaddr*>(&res.nsaddr_list[i]),
+ sizeof res.nsaddr_list[i])) {
return false;
}
dns_config->nameservers.push_back(ipe);
@@ -222,6 +223,12 @@ bool ConvertResStateToDnsConfig(const struct __res_state& res,
#endif
dns_config->edns0 = res.options & RES_USE_EDNS0;
+ // If any name server is 0.0.0.0, assume the configuration is invalid.
+ // TODO(szym): Measure how often this happens. http://crbug.com/125599
+ const IPAddressNumber kEmptyAddress(kIPv4AddressSize);
+ for (unsigned i = 0; i < dns_config->nameservers.size(); ++i)
+ if (dns_config->nameservers[i].address() == kEmptyAddress)
+ return false;
return true;
}
#endif // !defined(OS_ANDROID)
« no previous file with comments | « no previous file | net/dns/dns_config_service_posix_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698