Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 Loading... | |
| 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 |
| OLD | NEW |