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

Side by Side Diff: net/ftp/ftp_network_transaction.cc

Issue 598071: Really connect to the same server in FTP network transaction. (Closed)
Patch Set: updates Created 10 years, 10 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/base/nss_memio.c ('k') | net/ftp/ftp_network_transaction_unittest.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) 2010 The Chromium Authors. All rights reserved. Use of this 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. Use of this
2 // source code is governed by a BSD-style license that can be found in the 2 // source code is governed by a BSD-style license that can be found in the
3 // LICENSE file. 3 // LICENSE file.
4 4
5 #include "net/ftp/ftp_network_transaction.h" 5 #include "net/ftp/ftp_network_transaction.h"
6 6
7 #include "base/compiler_specific.h" 7 #include "base/compiler_specific.h"
8 #include "base/histogram.h" 8 #include "base/histogram.h"
9 #include "base/string_util.h" 9 #include "base/string_util.h"
10 #include "net/base/connection_type_histograms.h" 10 #include "net/base/connection_type_histograms.h"
(...skipping 1086 matching lines...) Expand 10 before | Expand all | Expand 10 after
1097 int FtpNetworkTransaction::ProcessResponseQUIT( 1097 int FtpNetworkTransaction::ProcessResponseQUIT(
1098 const FtpCtrlResponse& response) { 1098 const FtpCtrlResponse& response) {
1099 ctrl_socket_->Disconnect(); 1099 ctrl_socket_->Disconnect();
1100 return last_error_; 1100 return last_error_;
1101 } 1101 }
1102 1102
1103 // Data Connection 1103 // Data Connection
1104 1104
1105 int FtpNetworkTransaction::DoDataConnect() { 1105 int FtpNetworkTransaction::DoDataConnect() {
1106 next_state_ = STATE_DATA_CONNECT_COMPLETE; 1106 next_state_ = STATE_DATA_CONNECT_COMPLETE;
1107 AddressList data_addresses; 1107 AddressList data_address;
1108 // TODO(phajdan.jr): Use exactly same IP address as the control socket. 1108 // Connect to the same host as the control socket to prevent PASV port
1109 // If the DNS name resolves to several different IPs, and they are different 1109 // scanning attacks.
1110 // physical servers, this will break. However, that configuration is very rare 1110 int rv = ctrl_socket_->GetPeerAddress(&data_address);
1111 // in practice. 1111 if (rv != OK)
1112 data_addresses.Copy(addresses_.head()); 1112 return Stop(rv);
1113 data_addresses.SetPort(data_connection_port_); 1113 data_address.SetPort(data_connection_port_);
1114 data_socket_.reset(socket_factory_->CreateTCPClientSocket(data_addresses)); 1114 data_socket_.reset(socket_factory_->CreateTCPClientSocket(data_address));
1115 return data_socket_->Connect(&io_callback_, load_log_); 1115 return data_socket_->Connect(&io_callback_, load_log_);
1116 } 1116 }
1117 1117
1118 int FtpNetworkTransaction::DoDataConnectComplete(int result) { 1118 int FtpNetworkTransaction::DoDataConnectComplete(int result) {
1119 RecordDataConnectionError(result); 1119 RecordDataConnectionError(result);
1120 if (retr_failed_) { 1120 if (retr_failed_) {
1121 next_state_ = STATE_CTRL_WRITE_CWD; 1121 next_state_ = STATE_CTRL_WRITE_CWD;
1122 } else { 1122 } else {
1123 next_state_ = STATE_CTRL_WRITE_SIZE; 1123 next_state_ = STATE_CTRL_WRITE_SIZE;
1124 } 1124 }
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
1230 if (!had_error_type[type]) { 1230 if (!had_error_type[type]) {
1231 had_error_type[type] = true; 1231 had_error_type[type] = true;
1232 UMA_HISTOGRAM_ENUMERATION("Net.FtpDataConnectionErrorHappened", 1232 UMA_HISTOGRAM_ENUMERATION("Net.FtpDataConnectionErrorHappened",
1233 type, NUM_OF_NET_ERROR_TYPES); 1233 type, NUM_OF_NET_ERROR_TYPES);
1234 } 1234 }
1235 UMA_HISTOGRAM_ENUMERATION("Net.FtpDataConnectionErrorCount", 1235 UMA_HISTOGRAM_ENUMERATION("Net.FtpDataConnectionErrorCount",
1236 type, NUM_OF_NET_ERROR_TYPES); 1236 type, NUM_OF_NET_ERROR_TYPES);
1237 } 1237 }
1238 1238
1239 } // namespace net 1239 } // namespace net
OLDNEW
« no previous file with comments | « net/base/nss_memio.c ('k') | net/ftp/ftp_network_transaction_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698