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

Side by Side Diff: net/socket/socks_client_socket.cc

Issue 1854813004: Add SOCKS4 and SOCKS5 fuzzers. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Response to comments Created 4 years, 8 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
« no previous file with comments | « net/socket/socks5_client_socket_fuzzer.cc ('k') | net/socket/socks_client_socket_fuzzer.cc » ('j') | 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 <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/callback_helpers.h" 10 #include "base/callback_helpers.h"
(...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after
410 bytes_received_ += result; 410 bytes_received_ += result;
411 if (bytes_received_ < kReadHeaderSize) { 411 if (bytes_received_ < kReadHeaderSize) {
412 next_state_ = STATE_HANDSHAKE_READ; 412 next_state_ = STATE_HANDSHAKE_READ;
413 return OK; 413 return OK;
414 } 414 }
415 415
416 const SOCKS4ServerResponse* response = 416 const SOCKS4ServerResponse* response =
417 reinterpret_cast<const SOCKS4ServerResponse*>(buffer_.data()); 417 reinterpret_cast<const SOCKS4ServerResponse*>(buffer_.data());
418 418
419 if (response->reserved_null != 0x00) { 419 if (response->reserved_null != 0x00) {
420 LOG(ERROR) << "Unknown response from SOCKS server."; 420 DVLOG(1) << "Unknown response from SOCKS server.";
421 return ERR_SOCKS_CONNECTION_FAILED; 421 return ERR_SOCKS_CONNECTION_FAILED;
422 } 422 }
423 423
424 switch (response->code) { 424 switch (response->code) {
425 case kServerResponseOk: 425 case kServerResponseOk:
426 completed_handshake_ = true; 426 completed_handshake_ = true;
427 return OK; 427 return OK;
428 case kServerResponseRejected: 428 case kServerResponseRejected:
429 LOG(ERROR) << "SOCKS request rejected or failed"; 429 DVLOG(1) << "SOCKS request rejected or failed";
430 return ERR_SOCKS_CONNECTION_FAILED; 430 return ERR_SOCKS_CONNECTION_FAILED;
431 case kServerResponseNotReachable: 431 case kServerResponseNotReachable:
432 LOG(ERROR) << "SOCKS request failed because client is not running " 432 DVLOG(1) << "SOCKS request failed because client is not running "
433 << "identd (or not reachable from the server)"; 433 << "identd (or not reachable from the server)";
434 return ERR_SOCKS_CONNECTION_HOST_UNREACHABLE; 434 return ERR_SOCKS_CONNECTION_HOST_UNREACHABLE;
435 case kServerResponseMismatchedUserId: 435 case kServerResponseMismatchedUserId:
436 LOG(ERROR) << "SOCKS request failed because client's identd could " 436 DVLOG(1) << "SOCKS request failed because client's identd could "
437 << "not confirm the user ID string in the request"; 437 << "not confirm the user ID string in the request";
438 return ERR_SOCKS_CONNECTION_FAILED; 438 return ERR_SOCKS_CONNECTION_FAILED;
439 default: 439 default:
440 LOG(ERROR) << "SOCKS server sent unknown response"; 440 DVLOG(1) << "SOCKS server sent unknown response";
441 return ERR_SOCKS_CONNECTION_FAILED; 441 return ERR_SOCKS_CONNECTION_FAILED;
442 } 442 }
443 443
444 // Note: we ignore the last 6 bytes as specified by the SOCKS protocol 444 // Note: we ignore the last 6 bytes as specified by the SOCKS protocol
445 } 445 }
446 446
447 int SOCKSClientSocket::GetPeerAddress(IPEndPoint* address) const { 447 int SOCKSClientSocket::GetPeerAddress(IPEndPoint* address) const {
448 return transport_->socket()->GetPeerAddress(address); 448 return transport_->socket()->GetPeerAddress(address);
449 } 449 }
450 450
451 int SOCKSClientSocket::GetLocalAddress(IPEndPoint* address) const { 451 int SOCKSClientSocket::GetLocalAddress(IPEndPoint* address) const {
452 return transport_->socket()->GetLocalAddress(address); 452 return transport_->socket()->GetLocalAddress(address);
453 } 453 }
454 454
455 } // namespace net 455 } // namespace net
OLDNEW
« no previous file with comments | « net/socket/socks5_client_socket_fuzzer.cc ('k') | net/socket/socks_client_socket_fuzzer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698