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

Side by Side Diff: remoting/protocol/chromium_socket_factory.cc

Issue 722503002: Use uint16 for port numbers, misc edition (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Self-review Created 6 years, 1 month 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "remoting/protocol/chromium_socket_factory.h" 5 #include "remoting/protocol/chromium_socket_factory.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "jingle/glue/utils.h" 10 #include "jingle/glue/utils.h"
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 } 115 }
116 116
117 bool UdpPacketSocket::Init(const rtc::SocketAddress& local_address, 117 bool UdpPacketSocket::Init(const rtc::SocketAddress& local_address,
118 uint16 min_port, uint16 max_port) { 118 uint16 min_port, uint16 max_port) {
119 net::IPEndPoint local_endpoint; 119 net::IPEndPoint local_endpoint;
120 if (!jingle_glue::SocketAddressToIPEndPoint( 120 if (!jingle_glue::SocketAddressToIPEndPoint(
121 local_address, &local_endpoint)) { 121 local_address, &local_endpoint)) {
122 return false; 122 return false;
123 } 123 }
124 124
125 for (uint16 port = min_port; port <= max_port; ++port) { 125 for (uint32 port = min_port; port <= max_port; ++port) {
Peter Kasting 2014/11/12 23:53:55 The old code was unsafe if a caller passed 65535 f
126 socket_.reset(new net::UDPServerSocket(NULL, net::NetLog::Source())); 126 socket_.reset(new net::UDPServerSocket(NULL, net::NetLog::Source()));
127 int result = socket_->Listen( 127 int result = socket_->Listen(
128 net::IPEndPoint(local_endpoint.address(), port)); 128 net::IPEndPoint(local_endpoint.address(), static_cast<uint16>(port)));
129 if (result == net::OK) { 129 if (result == net::OK) {
130 break; 130 break;
131 } else { 131 } else {
132 socket_.reset(); 132 socket_.reset();
133 } 133 }
134 } 134 }
135 135
136 if (!socket_.get()) { 136 if (!socket_.get()) {
137 // Failed to bind the socket. 137 // Failed to bind the socket.
138 return false; 138 return false;
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after
390 return NULL; 390 return NULL;
391 } 391 }
392 392
393 rtc::AsyncResolverInterface* 393 rtc::AsyncResolverInterface*
394 ChromiumPacketSocketFactory::CreateAsyncResolver() { 394 ChromiumPacketSocketFactory::CreateAsyncResolver() {
395 return new rtc::AsyncResolver(); 395 return new rtc::AsyncResolver();
396 } 396 }
397 397
398 } // namespace protocol 398 } // namespace protocol
399 } // namespace remoting 399 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698