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

Unified Diff: chrome/browser/chromeos/login/owner_key_utils_unittest.cc

Issue 10399104: Fixes an issue when the owner key is empty chrome would crash trying to access bogus memory. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 7 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
Index: chrome/browser/chromeos/login/owner_key_utils_unittest.cc
diff --git a/chrome/browser/chromeos/login/owner_key_utils_unittest.cc b/chrome/browser/chromeos/login/owner_key_utils_unittest.cc
index 916b707b163ea5768737dbfa9d7bc50bd6b02c71..ebd053d513db97a0e81abb4ef3324b3f6d3651f0 100644
--- a/chrome/browser/chromeos/login/owner_key_utils_unittest.cc
+++ b/chrome/browser/chromeos/login/owner_key_utils_unittest.cc
@@ -65,4 +65,23 @@ TEST_F(OwnerKeyUtilsTest, ExportImportPublicKey) {
}
}
+TEST_F(OwnerKeyUtilsTest, ImportPublicKeyFailed) {
+ ScopedTempDir tmpdir;
+ FilePath tmpfile;
+ ASSERT_TRUE(tmpdir.CreateUniqueTempDir());
+
+ // First test the case where the file is missing which should fail.
+ std::vector<uint8> from_disk;
+ ASSERT_FALSE(utils_->ImportPublicKey(tmpfile, &from_disk));
+
+ // Next try empty file. This should not fail but the array should be empty.
+ from_disk.resize(10);
+ ASSERT_TRUE(file_util::CreateTemporaryFileInDir(tmpdir.path(), &tmpfile));
+ ASSERT_TRUE(utils_->ImportPublicKey(tmpfile, &from_disk));
+ ASSERT_FALSE(from_disk.size());
+
+ // TODO(pastarmovj): Do we want to have a test for the <4GB boundary? This
+ // will require quite some free space on the test bots.
Mattias Nissler (ping if slow) 2012/05/21 14:33:27 No. And this shouldn't be a TODO probably. If you
pastarmovj 2012/05/21 14:38:23 Done.
+}
+
} // namespace chromeos

Powered by Google App Engine
This is Rietveld 408576698