diff options
author | phajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-08 15:48:40 +0000 |
---|---|---|
committer | phajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-08 15:48:40 +0000 |
commit | dc5146bf943e7b7a0bcc7d77e25abc1a14687654 (patch) | |
tree | 07c06025ca3917bdf582d5f491cb4ceda744bdd2 /net/ftp/ftp_network_transaction.cc | |
parent | e1a0c893378d37d7a1c7f145638780a2ded2530c (diff) | |
download | chromium_src-dc5146bf943e7b7a0bcc7d77e25abc1a14687654.zip chromium_src-dc5146bf943e7b7a0bcc7d77e25abc1a14687654.tar.gz chromium_src-dc5146bf943e7b7a0bcc7d77e25abc1a14687654.tar.bz2 |
Correctly handle multiple control response lines in new FTP transaction
After this change it should correctly handle all cases of multiple 230 welcome responses. It also fixes some other related bugs.
TEST=Covered by net_unittests.
BUG=none
Review URL: http://codereview.chromium.org/149211
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@20148 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/ftp/ftp_network_transaction.cc')
-rw-r--r-- | net/ftp/ftp_network_transaction.cc | 30 |
1 files changed, 27 insertions, 3 deletions
diff --git a/net/ftp/ftp_network_transaction.cc b/net/ftp/ftp_network_transaction.cc index 5b3ff67..980e0ab 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); |