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

Unified Diff: net/ftp/ftp_network_transaction_unittest.cc

Issue 1827893002: Fix handling of escaped slashes ("%2f") in FTP paths. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove accidentally included test code Created 4 years, 9 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 | « net/ftp/ftp_network_transaction.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/ftp/ftp_network_transaction_unittest.cc
diff --git a/net/ftp/ftp_network_transaction_unittest.cc b/net/ftp/ftp_network_transaction_unittest.cc
index c1b98c84cac78275f81a3c3cc1f23c17a0dd817f..cf0b14e08c045d49a8eb5c5c1fd029baf2ab3889 100644
--- a/net/ftp/ftp_network_transaction_unittest.cc
+++ b/net/ftp/ftp_network_transaction_unittest.cc
@@ -430,6 +430,34 @@ class FtpSocketDataProviderFileDownload : public FtpSocketDataProvider {
DISALLOW_COPY_AND_ASSIGN(FtpSocketDataProviderFileDownload);
};
+class FtpSocketDataProviderPathSeparatorsNotUnescaped
+ : public FtpSocketDataProvider {
+ public:
+ FtpSocketDataProviderPathSeparatorsNotUnescaped() {}
+
+ MockWriteResult OnWrite(const std::string& data) override {
+ if (InjectFault())
+ return MockWriteResult(ASYNC, data.length());
+ switch (state()) {
+ case PRE_SIZE:
+ return Verify("SIZE /foo%2f..%2fbar%5c\r\n", data, PRE_CWD,
+ "213 18\r\n");
+ case PRE_CWD:
+ return Verify("CWD /foo%2f..%2fbar%5c\r\n", data,
+ use_epsv() ? PRE_RETR_EPSV : PRE_RETR_PASV,
+ "550 Not a directory\r\n");
+ case PRE_RETR:
+ return Verify("RETR /foo%2f..%2fbar%5c\r\n", data, PRE_QUIT,
+ "200 OK\r\n");
+ default:
+ return FtpSocketDataProvider::OnWrite(data);
+ }
+ }
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(FtpSocketDataProviderPathSeparatorsNotUnescaped);
+};
+
class FtpSocketDataProviderFileNotFound : public FtpSocketDataProvider {
public:
FtpSocketDataProviderFileNotFound() {
@@ -1309,6 +1337,18 @@ TEST_P(FtpNetworkTransactionTest, DownloadTransactionSpaceInPassword) {
ExecuteTransaction(&ctrl_socket, "ftp://test:hello%20world@host/file", OK);
}
+// Make sure FtpNetworkTransaction doesn't request paths like
+// "/foo/../bar". Doing so wouldn't be a security issue, client side, but just
+// doesn't seem like a good idea.
+TEST_P(FtpNetworkTransactionTest,
+ DownloadTransactionPathSeparatorsNotUnescaped) {
+ FtpSocketDataProviderPathSeparatorsNotUnescaped ctrl_socket;
+ ExecuteTransaction(&ctrl_socket, "ftp://host/foo%2f..%2fbar%5c", OK);
+
+ // We pass an artificial value of 18 as a response to the SIZE command.
+ EXPECT_EQ(18, transaction_.GetResponseInfo()->expected_content_size);
+}
+
TEST_P(FtpNetworkTransactionTest, EvilRestartUser) {
FtpSocketDataProvider ctrl_socket1;
ctrl_socket1.InjectFailure(FtpSocketDataProvider::PRE_PASSWD,
« no previous file with comments | « net/ftp/ftp_network_transaction.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698