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

Unified Diff: chrome/common/zip_unittest.cc

Issue 8437016: Fix subtle flakiness from ZipTest. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 2 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/common/zip_unittest.cc
diff --git a/chrome/common/zip_unittest.cc b/chrome/common/zip_unittest.cc
index dfffd0938c82ea70375d15e63d5d801d3db6b4a7..11087200b2f7f3cc45267468a0d548b075149eeb 100644
--- a/chrome/common/zip_unittest.cc
+++ b/chrome/common/zip_unittest.cc
@@ -99,8 +99,12 @@ TEST_F(ZipTest, UnzipEvil) {
FilePath path;
ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &path));
path = path.AppendASCII("zip").AppendASCII("evil.zip");
- ASSERT_FALSE(zip::Unzip(path, test_dir_));
- FilePath evil_file = test_dir_;
+ // Unzip the zip file into a sub directory of test_dir_ so evil.zip
+ // won't create a persistent file outside test_dir_ in case of a
+ // failure.
+ FilePath output_dir = test_dir_.AppendASCII("out");
+ ASSERT_FALSE(zip::Unzip(path, output_dir));
+ FilePath evil_file = output_dir;
evil_file = evil_file.AppendASCII(
"../levilevilevilevilevilevilevilevilevilevilevilevil");
ASSERT_FALSE(file_util::PathExists(evil_file));
@@ -110,8 +114,10 @@ TEST_F(ZipTest, UnzipEvil2) {
FilePath path;
ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &path));
path = path.AppendASCII("zip").AppendASCII("evil_via_invalid_utf8.zip");
- ASSERT_TRUE(zip::Unzip(path, test_dir_));
- FilePath evil_file = test_dir_;
+ // See the comment at UnzipEvil() for why we do this.
+ FilePath output_dir = test_dir_.AppendASCII("out");
+ ASSERT_TRUE(zip::Unzip(path, output_dir));
+ FilePath evil_file = output_dir;
evil_file = evil_file.AppendASCII("../evil.txt");
ASSERT_FALSE(file_util::PathExists(evil_file));
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698