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

Side by Side Diff: net/socket/socks_client_socket_unittest.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
« net/dns/host_resolver_impl.cc ('K') | « net/dns/mock_host_resolver.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/socket/socks_client_socket.h" 5 #include "net/socket/socks_client_socket.h"
6 6
7 #include "base/memory/scoped_ptr.h" 7 #include "base/memory/scoped_ptr.h"
8 #include "net/base/address_list.h" 8 #include "net/base/address_list.h"
9 #include "net/base/net_log.h" 9 #include "net/base/net_log.h"
10 #include "net/base/net_log_unittest.h" 10 #include "net/base/net_log_unittest.h"
11 #include "net/base/test_completion_callback.h" 11 #include "net/base/test_completion_callback.h"
12 #include "net/base/winsock_init.h" 12 #include "net/base/winsock_init.h"
13 #include "net/dns/host_resolver.h"
13 #include "net/dns/mock_host_resolver.h" 14 #include "net/dns/mock_host_resolver.h"
14 #include "net/socket/client_socket_factory.h" 15 #include "net/socket/client_socket_factory.h"
15 #include "net/socket/socket_test_util.h" 16 #include "net/socket/socket_test_util.h"
16 #include "net/socket/tcp_client_socket.h" 17 #include "net/socket/tcp_client_socket.h"
17 #include "testing/gtest/include/gtest/gtest.h" 18 #include "testing/gtest/include/gtest/gtest.h"
18 #include "testing/platform_test.h" 19 #include "testing/platform_test.h"
19 20
20 //----------------------------------------------------------------------------- 21 //-----------------------------------------------------------------------------
21 22
22 namespace net { 23 namespace net {
(...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after
407 408
408 // Disconnect the SOCKS socket -- this should cancel the outstanding resolve. 409 // Disconnect the SOCKS socket -- this should cancel the outstanding resolve.
409 user_sock_->Disconnect(); 410 user_sock_->Disconnect();
410 411
411 EXPECT_FALSE(hanging_resolver->HasOutstandingRequest()); 412 EXPECT_FALSE(hanging_resolver->HasOutstandingRequest());
412 413
413 EXPECT_FALSE(user_sock_->IsConnected()); 414 EXPECT_FALSE(user_sock_->IsConnected());
414 EXPECT_FALSE(user_sock_->IsConnectedAndIdle()); 415 EXPECT_FALSE(user_sock_->IsConnectedAndIdle());
415 } 416 }
416 417
418 // Tries to connect to an IPv6 IP. Should fail, as SOCKS4 does not support
419 // IPv6.
420 TEST_F(SOCKSClientSocketTest, NoIPv6) {
421 const char kHostName[] = "::1";
422
423 // Use a real HostResolver for this test, as the MockHostResolver has its own
Deprecated (see juliatuttle) 2014/08/04 20:32:20 Perhaps test the behavior of both of them, to ensu
mmenke 2014/08/05 22:50:38 Done.
424 // code to handle raw IP addresses, and this serves to test that code as
425 // well.
426 scoped_ptr<HostResolver> host_resolver(
427 HostResolver::CreateSystemResolver(HostResolver::Options(), NULL));
428
429 user_sock_ = BuildMockSocket(NULL, 0,
430 NULL, 0,
431 host_resolver.get(),
432 kHostName, 80,
433 NULL);
434
435 EXPECT_EQ(ERR_NAME_NOT_RESOLVED,
436 callback_.GetResult(user_sock_->Connect(callback_.callback())));
437 }
438
417 } // namespace net 439 } // namespace net
OLDNEW
« net/dns/host_resolver_impl.cc ('K') | « net/dns/mock_host_resolver.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698