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

Unified Diff: net/ftp/ftp_network_transaction.cc

Issue 149211: Correctly handle multiple control response lines in new FTP transaction (Closed)
Patch Set: fixes Created 11 years, 5 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 | « no previous file | net/ftp/ftp_network_transaction_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/ftp/ftp_network_transaction.cc
diff --git a/net/ftp/ftp_network_transaction.cc b/net/ftp/ftp_network_transaction.cc
index 5b3ff672975ae305a922977379257f2739a9f870..980e0abf01898095ccd3b495254f5b12c6200cb6 100644
--- a/net/ftp/ftp_network_transaction.cc
+++ b/net/ftp/ftp_network_transaction.cc
@@ -158,7 +158,11 @@ int FtpNetworkTransaction::ParseCtrlResponse(int* cut_pos) {
return ERR_INVALID_RESPONSE;
ctrl_responses_.push(ResponseLine(status_code, status_text));
*cut_pos = i + 1;
+
+ // Prepare to handle the next line.
scan_state = CODE;
+ status_code = 0;
+ status_text = "";
break;
default:
NOTREACHED();
@@ -172,7 +176,6 @@ int FtpNetworkTransaction::ParseCtrlResponse(int* cut_pos) {
// Used to prepare and send FTP commad.
int FtpNetworkTransaction::SendFtpCommand(const std::string& command,
Command cmd) {
- response_message_buf_len_ = 0;
command_sent_ = cmd;
DLOG(INFO) << " >> " << command;
const char* buf = command.c_str();
@@ -199,8 +202,29 @@ int FtpNetworkTransaction::ProcessCtrlResponses() {
return rv;
}
- // TODO(phajdan.jr): Correctly handle multiple code 230 response lines after
- // PASS command.
+ // Eat multiple 230 lines after PASS.
+ if (command_sent_ == COMMAND_PASS) {
+ while (ctrl_responses_.size() > 1) {
+ if (ctrl_responses_.front().code != 230)
+ break;
+ ctrl_responses_.pop();
+ }
+ }
+
+ // Make sure there are no 230's when we want to process SYST response.
+ if (command_sent_ == COMMAND_SYST) {
+ while (!ctrl_responses_.empty()) {
+ if (ctrl_responses_.front().code != 230)
+ break;
+ ctrl_responses_.pop();
+ }
+ if (ctrl_responses_.empty()) {
+ // Read more from control socket.
+ next_state_ = STATE_CTRL_READ;
+ return rv;
+ }
+ }
+
if (ctrl_responses_.size() != 1)
return Stop(ERR_INVALID_RESPONSE);
« no previous file with comments | « no previous file | net/ftp/ftp_network_transaction_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698