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

Side by Side Diff: net/dns/mock_host_resolver.cc

Issue 2294343003: Refuse to resolve some types of invalid DNS addresses. (Closed)
Patch Set: Oops Created 4 years, 3 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
« no previous file with comments | « net/dns/host_resolver_impl.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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"
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 AddressList* addresses, 106 AddressList* addresses,
107 const CompletionCallback& callback, 107 const CompletionCallback& callback,
108 std::unique_ptr<Request>* request, 108 std::unique_ptr<Request>* request,
109 const BoundNetLog& net_log) { 109 const BoundNetLog& net_log) {
110 DCHECK(CalledOnValidThread()); 110 DCHECK(CalledOnValidThread());
111 DCHECK(request); 111 DCHECK(request);
112 last_request_priority_ = priority; 112 last_request_priority_ = priority;
113 num_resolve_++; 113 num_resolve_++;
114 size_t id = next_request_id_++; 114 size_t id = next_request_id_++;
115 int rv = ResolveFromIPLiteralOrCache(info, addresses); 115 int rv = ResolveFromIPLiteralOrCache(info, addresses);
116 if (rv != ERR_DNS_CACHE_MISS) { 116 if (rv != ERR_DNS_CACHE_MISS)
117 return rv; 117 return rv;
118 } 118
119 if (synchronous_mode_) { 119 // Just like the real resolver, refuse to do anything with invalid hostnames.
120 if (!IsValidDNSDomain(info.hostname()))
121 return ERR_NAME_NOT_RESOLVED;
122
123 if (synchronous_mode_)
120 return ResolveProc(info, addresses); 124 return ResolveProc(info, addresses);
121 } 125
122 // Store the request for asynchronous resolution 126 // Store the request for asynchronous resolution
123 std::unique_ptr<RequestImpl> req( 127 std::unique_ptr<RequestImpl> req(
124 new RequestImpl(info, addresses, callback, this, id)); 128 new RequestImpl(info, addresses, callback, this, id));
125 requests_[id] = req.get(); 129 requests_[id] = req.get();
126 *request = std::move(req); 130 *request = std::move(req);
127 131
128 if (!ondemand_mode_) { 132 if (!ondemand_mode_) {
129 base::ThreadTaskRunnerHandle::Get()->PostTask( 133 base::ThreadTaskRunnerHandle::Get()->PostTask(
130 FROM_HERE, 134 FROM_HERE,
131 base::Bind(&MockHostResolverBase::ResolveNow, AsWeakPtr(), id)); 135 base::Bind(&MockHostResolverBase::ResolveNow, AsWeakPtr(), id));
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after
474 CHECK_EQ(old_proc, current_proc_.get()); 478 CHECK_EQ(old_proc, current_proc_.get());
475 } 479 }
476 480
477 void ScopedDefaultHostResolverProc::Init(HostResolverProc* proc) { 481 void ScopedDefaultHostResolverProc::Init(HostResolverProc* proc) {
478 current_proc_ = proc; 482 current_proc_ = proc;
479 previous_proc_ = HostResolverProc::SetDefault(current_proc_.get()); 483 previous_proc_ = HostResolverProc::SetDefault(current_proc_.get());
480 current_proc_->SetLastProc(previous_proc_.get()); 484 current_proc_->SetLastProc(previous_proc_.get());
481 } 485 }
482 486
483 } // namespace net 487 } // namespace net
OLDNEW
« no previous file with comments | « net/dns/host_resolver_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698