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

Unified Diff: chrome/installer/setup/archive_patch_helper_unittest.cc

Issue 2182873003: Add bounds check for negative ctrlsrc->z. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Created 4 years, 4 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 | chrome/test/data/installer/bin.old » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/installer/setup/archive_patch_helper_unittest.cc
diff --git a/chrome/installer/setup/archive_patch_helper_unittest.cc b/chrome/installer/setup/archive_patch_helper_unittest.cc
index f42ed5baffa6a9d214ec9f50732ec33f76d4496b..8e6c996be48981b4a5f95443582a2d9d85a09fba 100644
--- a/chrome/installer/setup/archive_patch_helper_unittest.cc
+++ b/chrome/installer/setup/archive_patch_helper_unittest.cc
@@ -59,3 +59,29 @@ TEST_F(ArchivePatchHelperTest, Patching) {
base::FilePath base = data_dir_.AppendASCII("archive2.7z");
EXPECT_TRUE(base::ContentsEqual(dest, base));
}
+
+TEST_F(ArchivePatchHelperTest, InvalidDiff_MisalignedCblen) {
+ base::FilePath src = data_dir_.AppendASCII("bin.old");
+ base::FilePath patch = data_dir_.AppendASCII("misaligned_cblen.diff");
+ base::FilePath dest = test_dir_.path().AppendASCII("bin.new");
+ installer::ArchivePatchHelper archive_helper(test_dir_.path(),
+ base::FilePath(),
+ src,
+ dest);
+ archive_helper.set_last_uncompressed_file(patch);
+ // Should fail, but not crash.
+ EXPECT_FALSE(archive_helper.BinaryPatch());
+}
+
+TEST_F(ArchivePatchHelperTest, InvalidDiff_NegativeSeek) {
+ base::FilePath src = data_dir_.AppendASCII("bin.old");
+ base::FilePath patch = data_dir_.AppendASCII("negative_seek.diff");
+ base::FilePath dest = test_dir_.path().AppendASCII("bin.new");
+ installer::ArchivePatchHelper archive_helper(test_dir_.path(),
+ base::FilePath(),
+ src,
+ dest);
+ archive_helper.set_last_uncompressed_file(patch);
+ // Should fail, but not crash.
+ EXPECT_FALSE(archive_helper.BinaryPatch());
+}
« no previous file with comments | « no previous file | chrome/test/data/installer/bin.old » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698