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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/chromeos/login/owner_key_utils.h" 5 #include "chrome/browser/chromeos/login/owner_key_utils.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/file_path.h" 10 #include "base/file_path.h"
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 58
59 std::vector<uint8>::iterator pubkey_it; 59 std::vector<uint8>::iterator pubkey_it;
60 std::vector<uint8>::iterator disk_it; 60 std::vector<uint8>::iterator disk_it;
61 for (pubkey_it = public_key.begin(), disk_it = from_disk.begin(); 61 for (pubkey_it = public_key.begin(), disk_it = from_disk.begin();
62 pubkey_it < public_key.end(); 62 pubkey_it < public_key.end();
63 pubkey_it++, disk_it++) { 63 pubkey_it++, disk_it++) {
64 EXPECT_EQ(*pubkey_it, *disk_it); 64 EXPECT_EQ(*pubkey_it, *disk_it);
65 } 65 }
66 } 66 }
67 67
68 TEST_F(OwnerKeyUtilsTest, ImportPublicKeyFailed) {
69 ScopedTempDir tmpdir;
70 FilePath tmpfile;
71 ASSERT_TRUE(tmpdir.CreateUniqueTempDir());
72
73 // First test the case where the file is missing which should fail.
74 std::vector<uint8> from_disk;
75 ASSERT_FALSE(utils_->ImportPublicKey(tmpfile, &from_disk));
76
77 // Next try empty file. This should fail and the array should be empty.
78 from_disk.resize(10);
79 ASSERT_TRUE(file_util::CreateTemporaryFileInDir(tmpdir.path(), &tmpfile));
80 ASSERT_FALSE(utils_->ImportPublicKey(tmpfile, &from_disk));
81 ASSERT_FALSE(from_disk.size());
82 }
83
68 } // namespace chromeos 84 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698