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

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: Changed the empty case to return false instead. 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..46db487237476e7aef08cfbb287314bdb2709c1c 100644
--- a/chrome/browser/chromeos/login/owner_key_utils_unittest.cc
+++ b/chrome/browser/chromeos/login/owner_key_utils_unittest.cc
@@ -65,4 +65,20 @@ 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 fail and the array should be empty.
+ from_disk.resize(10);
+ ASSERT_TRUE(file_util::CreateTemporaryFileInDir(tmpdir.path(), &tmpfile));
+ ASSERT_FALSE(utils_->ImportPublicKey(tmpfile, &from_disk));
+ ASSERT_FALSE(from_disk.size());
+}
+
} // namespace chromeos

Powered by Google App Engine
This is Rietveld 408576698