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

Unified 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: Response to eroman's comments 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/dns/mock_host_resolver.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/socket/socks_client_socket_unittest.cc
diff --git a/net/socket/socks_client_socket_unittest.cc b/net/socket/socks_client_socket_unittest.cc
index f361244feff01a7dfa3138a7bc4ded1f36b13e29..c8032e694b7a240a51148169c1528314e729d543 100644
--- a/net/socket/socks_client_socket_unittest.cc
+++ b/net/socket/socks_client_socket_unittest.cc
@@ -10,6 +10,7 @@
#include "net/base/net_log_unittest.h"
#include "net/base/test_completion_callback.h"
#include "net/base/winsock_init.h"
+#include "net/dns/host_resolver.h"
#include "net/dns/mock_host_resolver.h"
#include "net/socket/client_socket_factory.h"
#include "net/socket/socket_test_util.h"
@@ -414,4 +415,36 @@ TEST_F(SOCKSClientSocketTest, DisconnectWhileHostResolveInProgress) {
EXPECT_FALSE(user_sock_->IsConnectedAndIdle());
}
+// Tries to connect to an IPv6 IP. Should fail, as SOCKS4 does not support
+// IPv6.
+TEST_F(SOCKSClientSocketTest, NoIPv6) {
+ const char kHostName[] = "::1";
+
+ user_sock_ = BuildMockSocket(NULL, 0,
+ NULL, 0,
+ host_resolver_.get(),
+ kHostName, 80,
+ NULL);
+
+ EXPECT_EQ(ERR_NAME_NOT_RESOLVED,
+ callback_.GetResult(user_sock_->Connect(callback_.callback())));
+}
+
+// Same as above, but with a real resolver, to protect against regressions.
+TEST_F(SOCKSClientSocketTest, NoIPv6RealResolver) {
+ const char kHostName[] = "::1";
+
+ scoped_ptr<HostResolver> host_resolver(
+ HostResolver::CreateSystemResolver(HostResolver::Options(), NULL));
+
+ user_sock_ = BuildMockSocket(NULL, 0,
+ NULL, 0,
+ host_resolver.get(),
+ kHostName, 80,
+ NULL);
+
+ EXPECT_EQ(ERR_NAME_NOT_RESOLVED,
+ callback_.GetResult(user_sock_->Connect(callback_.callback())));
+}
+
} // namespace net
« no previous file with comments | « net/dns/mock_host_resolver.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698