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

Unified Diff: net/socket/socks5_client_socket.cc

Issue 501112: Add two more unit tests for SOCKS5:... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Add back a header file Created 11 years 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 | « no previous file | net/socket/socks5_client_socket_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/socket/socks5_client_socket.cc
===================================================================
--- net/socket/socks5_client_socket.cc (revision 34990)
+++ net/socket/socks5_client_socket.cc (working copy)
@@ -85,7 +85,7 @@
// Read is called by the transport layer above to read. This can only be done
// if the SOCKS handshake is complete.
int SOCKS5ClientSocket::Read(IOBuffer* buf, int buf_len,
- CompletionCallback* callback) {
+ CompletionCallback* callback) {
DCHECK(completed_handshake_);
DCHECK_EQ(STATE_NONE, next_state_);
DCHECK(!user_callback_);
@@ -182,6 +182,11 @@
const char kSOCKS5GreetReadData[] = { 0x05, 0x00 };
int SOCKS5ClientSocket::DoGreetWrite() {
+ // Since we only have 1 byte to send the hostname length in, if the
+ // URL has a hostname longer than 255 characters we can't send it.
+ if (0xFF < host_request_info_.hostname().size())
+ return ERR_INVALID_URL;
+
if (buffer_.empty()) {
buffer_ = std::string(kSOCKS5GreetWriteData,
arraysize(kSOCKS5GreetWriteData));
@@ -251,10 +256,7 @@
handshake->push_back(kEndPointDomain); // The type of the address.
- // We only have 1 byte to send the length in, so if the hostname is
- // longer than this we can't send it!
- if(256 <= host_request_info_.hostname().size())
- return ERR_INVALID_URL;
+ DCHECK_GE(static_cast<size_t>(0xFF), host_request_info_.hostname().size());
// First add the size of the hostname, followed by the hostname.
handshake->push_back(static_cast<unsigned char>(
« no previous file with comments | « no previous file | net/socket/socks5_client_socket_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698