summaryrefslogtreecommitdiffstats
path: root/net/ftp
diff options
context:
space:
mode:
authorphajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-12-20 12:15:38 +0000
committerphajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-12-20 12:15:38 +0000
commitddb92f133c7776004575d4c9c52cf709f5082dcc (patch)
tree2164bb6e39f817c0fbb3026366421f5611fc81c9 /net/ftp
parent0eb45522182b6ac9d489cc801eb2eca293021a30 (diff)
downloadchromium_src-ddb92f133c7776004575d4c9c52cf709f5082dcc.zip
chromium_src-ddb92f133c7776004575d4c9c52cf709f5082dcc.tar.gz
chromium_src-ddb92f133c7776004575d4c9c52cf709f5082dcc.tar.bz2
FTP: work around server bugs resulting in negative file size being sent.
BUG=106841 Review URL: http://codereview.chromium.org/8970023 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@115115 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/ftp')
-rw-r--r--net/ftp/ftp_directory_listing_parser_ls.cc9
-rw-r--r--net/ftp/ftp_directory_listing_parser_ls_unittest.cc5
2 files changed, 10 insertions, 4 deletions
diff --git a/net/ftp/ftp_directory_listing_parser_ls.cc b/net/ftp/ftp_directory_listing_parser_ls.cc
index ec99700..5c2e4e9 100644
--- a/net/ftp/ftp_directory_listing_parser_ls.cc
+++ b/net/ftp/ftp_directory_listing_parser_ls.cc
@@ -187,8 +187,13 @@ bool ParseFtpDirectoryListingLs(
// TODO(phajdan.jr): Use a value that means "unknown" instead of 0 bytes.
entry.size = 0;
}
- if (entry.size < 0)
- return false;
+ if (entry.size < 0) {
+ // Some FTP servers have bugs that cause them to display the file size
+ // as negative. They're most likely big files like DVD ISO images.
+ // We still want to display them, so just say the real file size
+ // is unknown.
+ entry.size = -1;
+ }
if (entry.type != FtpDirectoryListingEntry::FILE)
entry.size = -1;
diff --git a/net/ftp/ftp_directory_listing_parser_ls_unittest.cc b/net/ftp/ftp_directory_listing_parser_ls_unittest.cc
index 4779a3c..b14d5c0 100644
--- a/net/ftp/ftp_directory_listing_parser_ls_unittest.cc
+++ b/net/ftp/ftp_directory_listing_parser_ls_unittest.cc
@@ -50,6 +50,9 @@ TEST_F(FtpDirectoryListingParserLsTest, Good) {
{ "lrwxrwxrwx 1 0 0 26 Sep 18 2008 pub",
FtpDirectoryListingEntry::SYMLINK, "pub", -1,
2008, 9, 18, 0, 0 },
+ { "-rw-r--r-- 1 ftp ftp -528 Nov 01 2007 README",
+ FtpDirectoryListingEntry::FILE, "README", -1,
+ 2007, 11, 1, 0, 0 },
// Tests for the wu-ftpd variant:
{ "drwxr-xr-x 2 sys 512 Mar 27 2009 pub",
@@ -161,12 +164,10 @@ TEST_F(FtpDirectoryListingParserLsTest, Bad) {
"-rw-r--r-- ftp ftp",
"-rw-rgbr-- ftp ftp 528 Nov 01 2007 README",
"qrwwr--r-- ftp ftp 528 Nov 01 2007 README",
- "-rw-r--r-- ftp ftp -528 Nov 01 2007 README",
"-rw-r--r-- ftp ftp 528 Foo 01 2007 README",
"-rw-r--r-- 1 ftp ftp",
"-rw-rgbr-- 1 ftp ftp 528 Nov 01 2007 README",
"qrwwr--r-- 1 ftp ftp 528 Nov 01 2007 README",
- "-rw-r--r-- 1 ftp ftp -528 Nov 01 2007 README",
"-rw-r--r-- 1 ftp ftp 528 Foo 01 2007 README",
"drwxrwxrwx 1 owner group 1024 Sep 13 0:3 audio",