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

Unified Diff: net/dns/mock_host_resolver.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 eroman'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 | « net/dns/host_resolver_impl_unittest.cc ('k') | net/socket/socks_client_socket_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/dns/mock_host_resolver.cc
diff --git a/net/dns/mock_host_resolver.cc b/net/dns/mock_host_resolver.cc
index ff5ffbc2f75082cbd83aae9a512cd7096d895b26..92ecbafebe11ac719f642d1a4e4ee215cb6a3b95 100644
--- a/net/dns/mock_host_resolver.cc
+++ b/net/dns/mock_host_resolver.cc
@@ -14,6 +14,7 @@
#include "base/strings/string_split.h"
#include "base/strings/string_util.h"
#include "base/threading/platform_thread.h"
+#include "net/base/ip_endpoint.h"
#include "net/base/net_errors.h"
#include "net/base/net_util.h"
#include "net/base/test_completion_callback.h"
@@ -154,6 +155,12 @@ int MockHostResolverBase::ResolveFromIPLiteralOrCache(const RequestInfo& info,
AddressList* addresses) {
IPAddressNumber ip;
if (ParseIPLiteralToNumber(info.hostname(), &ip)) {
+ // This matches the behavior HostResolverImpl.
+ if (info.address_family() != ADDRESS_FAMILY_UNSPECIFIED &&
+ info.address_family() != GetAddressFamily(ip)) {
+ return ERR_NAME_NOT_RESOLVED;
+ }
+
*addresses = AddressList::CreateFromIPAddress(ip, info.port());
if (info.host_resolver_flags() & HOST_RESOLVER_CANONNAME)
addresses->SetDefaultCanonicalName();
« no previous file with comments | « net/dns/host_resolver_impl_unittest.cc ('k') | net/socket/socks_client_socket_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698