diff options
author | inferno@chromium.org <inferno@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-04-08 17:20:26 +0000 |
---|---|---|
committer | inferno@chromium.org <inferno@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-04-08 17:20:26 +0000 |
commit | 90ae6d032f7f3455747072fbd55dee07cdc16620 (patch) | |
tree | d23f34d2f1006217eb1b1ac7278270fd41d42657 /net | |
parent | a1320d6fb775ac75285f07064ad57630ce02e9e9 (diff) | |
download | chromium_src-90ae6d032f7f3455747072fbd55dee07cdc16620.zip chromium_src-90ae6d032f7f3455747072fbd55dee07cdc16620.tar.gz chromium_src-90ae6d032f7f3455747072fbd55dee07cdc16620.tar.bz2 |
Fix out of array bounds access in VMSPathToUnix function.
BUG=40801
TEST=FtpUtilTest.VMSPathToUnix
Review URL: http://codereview.chromium.org/1566029
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@43961 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net')
-rw-r--r-- | net/ftp/ftp_util.cc | 2 | ||||
-rw-r--r-- | net/ftp/ftp_util_unittest.cc | 1 |
2 files changed, 2 insertions, 1 deletions
diff --git a/net/ftp/ftp_util.cc b/net/ftp/ftp_util.cc index ff9aaa9..79e6b71 100644 --- a/net/ftp/ftp_util.cc +++ b/net/ftp/ftp_util.cc @@ -100,7 +100,7 @@ std::string FtpUtil::VMSPathToUnix(const std::string& vms_path) { std::replace(result.begin(), result.end(), ']', '/'); // Make sure the result doesn't end with a slash. - if (result[result.length() - 1] == '/') + if (result.length() && result[result.length() - 1] == '/') result = result.substr(0, result.length() - 1); return result; diff --git a/net/ftp/ftp_util_unittest.cc b/net/ftp/ftp_util_unittest.cc index 480c893..20450c2 100644 --- a/net/ftp/ftp_util_unittest.cc +++ b/net/ftp/ftp_util_unittest.cc @@ -94,6 +94,7 @@ TEST(FtpUtilTest, VMSPathToUnix) { { "[.a.b.c]", "a/b/c" }, { "[.a.b.c]d", "a/b/c/d" }, { "[.a.b.c.d]", "a/b/c/d" }, + { "[.", "" }, }; for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kTestCases); i++) { EXPECT_EQ(kTestCases[i].expected_output, |