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

Side by Side Diff: webrtc/p2p/base/turnport_unittest.cc

Issue 2445933003: Fix "IsLoopbackIp" to cover all loopback addresses; not just 127.0.0.1. (Closed)
Patch Set: Created 4 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
« no previous file with comments | « webrtc/base/ipaddress_unittest.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 /* 1 /*
2 * Copyright 2012 The WebRTC Project Authors. All rights reserved. 2 * Copyright 2012 The WebRTC Project Authors. All rights reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 #if defined(WEBRTC_POSIX) 10 #if defined(WEBRTC_POSIX)
(...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after
445 // A certain security exploit works by redirecting to a loopback address, 445 // A certain security exploit works by redirecting to a loopback address,
446 // which doesn't ever actually make sense. So redirects to loopback should 446 // which doesn't ever actually make sense. So redirects to loopback should
447 // be treated as errors. 447 // be treated as errors.
448 // See: https://bugs.chromium.org/p/chromium/issues/detail?id=649118 448 // See: https://bugs.chromium.org/p/chromium/issues/detail?id=649118
449 void TestTurnAlternateServerLoopback(ProtocolType protocol_type, bool ipv6) { 449 void TestTurnAlternateServerLoopback(ProtocolType protocol_type, bool ipv6) {
450 const SocketAddress& local_address = ipv6 ? kLocalIPv6Addr : kLocalAddr1; 450 const SocketAddress& local_address = ipv6 ? kLocalIPv6Addr : kLocalAddr1;
451 const SocketAddress& server_address = 451 const SocketAddress& server_address =
452 ipv6 ? kTurnIPv6IntAddr : kTurnIntAddr; 452 ipv6 ? kTurnIPv6IntAddr : kTurnIntAddr;
453 453
454 std::vector<rtc::SocketAddress> redirect_addresses; 454 std::vector<rtc::SocketAddress> redirect_addresses;
455 SocketAddress loopback_address(ipv6 ? "::1" : "127.0.0.1", 455 // Pick an unusual address in the 127.0.0.0/8 range to make sure more than
456 // 127.0.0.1 is covered.
457 SocketAddress loopback_address(ipv6 ? "::1" : "127.1.2.3",
456 TURN_SERVER_PORT); 458 TURN_SERVER_PORT);
457 redirect_addresses.push_back(loopback_address); 459 redirect_addresses.push_back(loopback_address);
458 460
459 // Make a socket and bind it to the local port, to make extra sure no 461 // Make a socket and bind it to the local port, to make extra sure no
460 // packet is sent to this address. 462 // packet is sent to this address.
461 std::unique_ptr<rtc::Socket> loopback_socket(ss_->CreateSocket( 463 std::unique_ptr<rtc::Socket> loopback_socket(ss_->CreateSocket(
462 protocol_type == PROTO_UDP ? SOCK_DGRAM : SOCK_STREAM)); 464 protocol_type == PROTO_UDP ? SOCK_DGRAM : SOCK_STREAM));
463 ASSERT_NE(nullptr, loopback_socket.get()); 465 ASSERT_NE(nullptr, loopback_socket.get());
464 ASSERT_EQ(0, loopback_socket->Bind(loopback_address)); 466 ASSERT_EQ(0, loopback_socket->Bind(loopback_address));
465 if (protocol_type == PROTO_TCP) { 467 if (protocol_type == PROTO_TCP) {
(...skipping 787 matching lines...) Expand 10 before | Expand all | Expand 10 after
1253 EXPECT_TRUE(turn_port_->Candidates().empty()); 1255 EXPECT_TRUE(turn_port_->Candidates().empty());
1254 turn_port_.reset(); 1256 turn_port_.reset();
1255 rtc::Thread::Current()->Post(RTC_FROM_HERE, this, MSG_TESTFINISH); 1257 rtc::Thread::Current()->Post(RTC_FROM_HERE, this, MSG_TESTFINISH);
1256 // Waiting for above message to be processed. 1258 // Waiting for above message to be processed.
1257 ASSERT_TRUE_SIMULATED_WAIT(test_finish_, 1, fake_clock_); 1259 ASSERT_TRUE_SIMULATED_WAIT(test_finish_, 1, fake_clock_);
1258 EXPECT_EQ(last_fd_count, GetFDCount()); 1260 EXPECT_EQ(last_fd_count, GetFDCount());
1259 } 1261 }
1260 #endif 1262 #endif
1261 1263
1262 } // namespace cricket 1264 } // namespace cricket
OLDNEW
« no previous file with comments | « webrtc/base/ipaddress_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698