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

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

Issue 2528713002: Fix some FTP DCHECKs on 1xx responses. (Closed)
Patch Set: Created 4 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 unified diff | Download patch
« no previous file with comments | « no previous file | 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) 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/ftp/ftp_network_transaction.h" 5 #include "net/ftp/ftp_network_transaction.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/compiler_specific.h" 9 #include "base/compiler_specific.h"
10 #include "base/metrics/histogram_macros.h" 10 #include "base/metrics/histogram_macros.h"
(...skipping 735 matching lines...) Expand 10 before | Expand all | Expand 10 after
746 if (!IsValidFTPCommandString(command)) 746 if (!IsValidFTPCommandString(command))
747 return Stop(ERR_MALFORMED_IDENTITY); 747 return Stop(ERR_MALFORMED_IDENTITY);
748 748
749 next_state_ = STATE_CTRL_READ; 749 next_state_ = STATE_CTRL_READ;
750 return SendFtpCommand(command, "USER ***", COMMAND_USER); 750 return SendFtpCommand(command, "USER ***", COMMAND_USER);
751 } 751 }
752 752
753 int FtpNetworkTransaction::ProcessResponseUSER( 753 int FtpNetworkTransaction::ProcessResponseUSER(
754 const FtpCtrlResponse& response) { 754 const FtpCtrlResponse& response) {
755 switch (GetErrorClass(response.status_code)) { 755 switch (GetErrorClass(response.status_code)) {
756 case ERROR_CLASS_INITIATED:
757 return Stop(ERR_INVALID_RESPONSE);
756 case ERROR_CLASS_OK: 758 case ERROR_CLASS_OK:
757 next_state_ = STATE_CTRL_WRITE_SYST; 759 next_state_ = STATE_CTRL_WRITE_SYST;
758 break; 760 break;
759 case ERROR_CLASS_INFO_NEEDED: 761 case ERROR_CLASS_INFO_NEEDED:
760 next_state_ = STATE_CTRL_WRITE_PASS; 762 next_state_ = STATE_CTRL_WRITE_PASS;
761 break; 763 break;
762 case ERROR_CLASS_TRANSIENT_ERROR: 764 case ERROR_CLASS_TRANSIENT_ERROR:
763 case ERROR_CLASS_PERMANENT_ERROR: 765 case ERROR_CLASS_PERMANENT_ERROR:
764 response_.needs_auth = true; 766 response_.needs_auth = true;
765 return Stop(GetNetErrorCodeForFtpResponseCode(response.status_code)); 767 return Stop(GetNetErrorCodeForFtpResponseCode(response.status_code));
766 default: 768 default:
eroman 2016/11/23 20:46:41 Can you remove the default case?
mmenke 2016/11/23 20:52:34 Done, removed them all (There are 11 methods just
767 NOTREACHED(); 769 NOTREACHED();
768 return Stop(ERR_UNEXPECTED); 770 return Stop(ERR_UNEXPECTED);
769 } 771 }
770 return OK; 772 return OK;
771 } 773 }
772 774
773 // PASS command. 775 // PASS command.
774 int FtpNetworkTransaction::DoCtrlWritePASS() { 776 int FtpNetworkTransaction::DoCtrlWritePASS() {
775 std::string command = "PASS " + base::UTF16ToUTF8(credentials_.password()); 777 std::string command = "PASS " + base::UTF16ToUTF8(credentials_.password());
776 778
777 if (!IsValidFTPCommandString(command)) 779 if (!IsValidFTPCommandString(command))
778 return Stop(ERR_MALFORMED_IDENTITY); 780 return Stop(ERR_MALFORMED_IDENTITY);
779 781
780 next_state_ = STATE_CTRL_READ; 782 next_state_ = STATE_CTRL_READ;
781 return SendFtpCommand(command, "PASS ***", COMMAND_PASS); 783 return SendFtpCommand(command, "PASS ***", COMMAND_PASS);
782 } 784 }
783 785
784 int FtpNetworkTransaction::ProcessResponsePASS( 786 int FtpNetworkTransaction::ProcessResponsePASS(
785 const FtpCtrlResponse& response) { 787 const FtpCtrlResponse& response) {
786 switch (GetErrorClass(response.status_code)) { 788 switch (GetErrorClass(response.status_code)) {
789 case ERROR_CLASS_INITIATED:
790 return Stop(ERR_INVALID_RESPONSE);
787 case ERROR_CLASS_OK: 791 case ERROR_CLASS_OK:
788 next_state_ = STATE_CTRL_WRITE_SYST; 792 next_state_ = STATE_CTRL_WRITE_SYST;
789 break; 793 break;
790 case ERROR_CLASS_INFO_NEEDED: 794 case ERROR_CLASS_INFO_NEEDED:
791 return Stop(GetNetErrorCodeForFtpResponseCode(response.status_code)); 795 return Stop(GetNetErrorCodeForFtpResponseCode(response.status_code));
792 case ERROR_CLASS_TRANSIENT_ERROR: 796 case ERROR_CLASS_TRANSIENT_ERROR:
793 case ERROR_CLASS_PERMANENT_ERROR: 797 case ERROR_CLASS_PERMANENT_ERROR:
794 response_.needs_auth = true; 798 response_.needs_auth = true;
795 return Stop(GetNetErrorCodeForFtpResponseCode(response.status_code)); 799 return Stop(GetNetErrorCodeForFtpResponseCode(response.status_code));
796 default: 800 default:
eroman 2016/11/23 20:46:41 ditto.
797 NOTREACHED(); 801 NOTREACHED();
798 return Stop(ERR_UNEXPECTED); 802 return Stop(ERR_UNEXPECTED);
799 } 803 }
800 return OK; 804 return OK;
801 } 805 }
802 806
803 // SYST command. 807 // SYST command.
804 int FtpNetworkTransaction::DoCtrlWriteSYST() { 808 int FtpNetworkTransaction::DoCtrlWriteSYST() {
805 std::string command = "SYST"; 809 std::string command = "SYST";
806 next_state_ = STATE_CTRL_READ; 810 next_state_ = STATE_CTRL_READ;
(...skipping 565 matching lines...) Expand 10 before | Expand all | Expand 10 after
1372 if (!had_error_type[type]) { 1376 if (!had_error_type[type]) {
1373 had_error_type[type] = true; 1377 had_error_type[type] = true;
1374 UMA_HISTOGRAM_ENUMERATION("Net.FtpDataConnectionErrorHappened", 1378 UMA_HISTOGRAM_ENUMERATION("Net.FtpDataConnectionErrorHappened",
1375 type, NUM_OF_NET_ERROR_TYPES); 1379 type, NUM_OF_NET_ERROR_TYPES);
1376 } 1380 }
1377 UMA_HISTOGRAM_ENUMERATION("Net.FtpDataConnectionErrorCount", 1381 UMA_HISTOGRAM_ENUMERATION("Net.FtpDataConnectionErrorCount",
1378 type, NUM_OF_NET_ERROR_TYPES); 1382 type, NUM_OF_NET_ERROR_TYPES);
1379 } 1383 }
1380 1384
1381 } // namespace net 1385 } // namespace net
OLDNEW
« 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