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

Unified Diff: net/dns/host_resolver_impl.cc

Issue 435603008: Fix crash when trying to connect to an IPv6 IP via a SOCKS4 proxy. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Response to ttuttle's comments. Created 6 years, 4 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/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 d5602a4c674cad2848bb9d28cc77b0ad85d5333f..b91a43b1992e8ac5d9caa3c5761023cb82ea33c7 100644
--- a/net/dns/host_resolver_impl.cc
+++ b/net/dns/host_resolver_impl.cc
@@ -35,6 +35,7 @@
#include "net/base/dns_reloader.h"
#include "net/base/dns_util.h"
#include "net/base/host_port_pair.h"
+#include "net/base/ip_endpoint.h"
#include "net/base/net_errors.h"
#include "net/base/net_log.h"
#include "net/base/net_util.h"
@@ -182,7 +183,7 @@ bool IsGloballyReachable(const IPAddressNumber& dest,
rv = socket->GetLocalAddress(&endpoint);
if (rv != OK)
return false;
- DCHECK(endpoint.GetFamily() == ADDRESS_FAMILY_IPV6);
+ DCHECK_EQ(ADDRESS_FAMILY_IPV6, endpoint.GetFamily());
const IPAddressNumber& address = endpoint.address();
bool is_link_local = (address[0] == 0xFE) && ((address[1] & 0xC0) == 0x80);
if (is_link_local)
@@ -2032,10 +2033,18 @@ bool HostResolverImpl::ResolveAsIP(const Key& key,
~(HOST_RESOLVER_CANONNAME | HOST_RESOLVER_LOOPBACK_ONLY |
HOST_RESOLVER_DEFAULT_FAMILY_SET_DUE_TO_NO_IPV6),
0) << " Unhandled flag";
- bool ipv6_disabled = (default_address_family_ == ADDRESS_FAMILY_IPV4) &&
- !probe_ipv6_support_;
+
*net_error = OK;
- if ((ip_number.size() == kIPv6AddressSize) && ipv6_disabled) {
+ AddressFamily family = GetAddressFamily(ip_number);
+ if (family == ADDRESS_FAMILY_IPV6 &&
+ default_address_family_ == ADDRESS_FAMILY_IPV4 &&
eroman 2014/08/05 22:33:41 As an aside: I am starting to think that "default
mmenke 2014/08/05 22:50:38 I agree that this would be much clearer.
+ !probe_ipv6_support_) {
eroman 2014/08/05 22:33:41 Can you test for !probe_ipv6_support_ before defau
mmenke 2014/08/05 22:50:38 Done.
+ // Don't return IPv6 addresses if default address family is set to IPv4,
+ // and probes are disabled.
+ *net_error = ERR_NAME_NOT_RESOLVED;
+ } else if (key.address_family != ADDRESS_FAMILY_UNSPECIFIED &&
+ key.address_family != family) {
+ // Don't return IPv6 addresses for IPv4 queries, and vice versa.
*net_error = ERR_NAME_NOT_RESOLVED;
} else {
*addresses = AddressList::CreateFromIPAddress(ip_number, info.port());
« no previous file with comments | « no previous file | net/dns/host_resolver_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698