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

Side by Side 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: Fix a couple issues 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "net/dns/mock_host_resolver.h" 5 #include "net/dns/mock_host_resolver.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/memory/ref_counted.h" 11 #include "base/memory/ref_counted.h"
12 #include "base/message_loop/message_loop.h" 12 #include "base/message_loop/message_loop.h"
13 #include "base/stl_util.h" 13 #include "base/stl_util.h"
14 #include "base/strings/string_split.h" 14 #include "base/strings/string_split.h"
15 #include "base/strings/string_util.h" 15 #include "base/strings/string_util.h"
16 #include "base/threading/platform_thread.h" 16 #include "base/threading/platform_thread.h"
17 #include "net/base/ip_endpoint.h"
17 #include "net/base/net_errors.h" 18 #include "net/base/net_errors.h"
18 #include "net/base/net_util.h" 19 #include "net/base/net_util.h"
19 #include "net/base/test_completion_callback.h" 20 #include "net/base/test_completion_callback.h"
20 #include "net/dns/host_cache.h" 21 #include "net/dns/host_cache.h"
21 22
22 #if defined(OS_WIN) 23 #if defined(OS_WIN)
23 #include "net/base/winsock_init.h" 24 #include "net/base/winsock_init.h"
24 #endif 25 #endif
25 26
26 namespace net { 27 namespace net {
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 148
148 if (use_caching) { 149 if (use_caching) {
149 cache_.reset(new HostCache(kMaxCacheEntries)); 150 cache_.reset(new HostCache(kMaxCacheEntries));
150 } 151 }
151 } 152 }
152 153
153 int MockHostResolverBase::ResolveFromIPLiteralOrCache(const RequestInfo& info, 154 int MockHostResolverBase::ResolveFromIPLiteralOrCache(const RequestInfo& info,
154 AddressList* addresses) { 155 AddressList* addresses) {
155 IPAddressNumber ip; 156 IPAddressNumber ip;
156 if (ParseIPLiteralToNumber(info.hostname(), &ip)) { 157 if (ParseIPLiteralToNumber(info.hostname(), &ip)) {
158 // This matches the behavior HostResolverImpl.
159 if (info.address_family() != ADDRESS_FAMILY_UNSPECIFIED &&
160 info.address_family() != GetAddressFamily(ip)) {
161 return ERR_NAME_NOT_RESOLVED;
162 }
163
157 *addresses = AddressList::CreateFromIPAddress(ip, info.port()); 164 *addresses = AddressList::CreateFromIPAddress(ip, info.port());
158 if (info.host_resolver_flags() & HOST_RESOLVER_CANONNAME) 165 if (info.host_resolver_flags() & HOST_RESOLVER_CANONNAME)
159 addresses->SetDefaultCanonicalName(); 166 addresses->SetDefaultCanonicalName();
160 return OK; 167 return OK;
161 } 168 }
162 int rv = ERR_DNS_CACHE_MISS; 169 int rv = ERR_DNS_CACHE_MISS;
163 if (cache_.get() && info.allow_cached_response()) { 170 if (cache_.get() && info.allow_cached_response()) {
164 HostCache::Key key(info.hostname(), 171 HostCache::Key key(info.hostname(),
165 info.address_family(), 172 info.address_family(),
166 info.host_resolver_flags()); 173 info.host_resolver_flags());
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after
436 CHECK_EQ(old_proc, current_proc_); 443 CHECK_EQ(old_proc, current_proc_);
437 } 444 }
438 445
439 void ScopedDefaultHostResolverProc::Init(HostResolverProc* proc) { 446 void ScopedDefaultHostResolverProc::Init(HostResolverProc* proc) {
440 current_proc_ = proc; 447 current_proc_ = proc;
441 previous_proc_ = HostResolverProc::SetDefault(current_proc_.get()); 448 previous_proc_ = HostResolverProc::SetDefault(current_proc_.get());
442 current_proc_->SetLastProc(previous_proc_.get()); 449 current_proc_->SetLastProc(previous_proc_.get());
443 } 450 }
444 451
445 } // namespace net 452 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698