OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/common/component_flash_hint_file_linux.h" | 5 #include "chrome/common/component_flash_hint_file_linux.h" |
6 | 6 |
7 #include <fcntl.h> | 7 #include <fcntl.h> |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 #include <sys/mman.h> | 10 #include <sys/mman.h> |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 } | 126 } |
127 | 127 |
128 bool RecordFlashUpdate(const base::FilePath& unpacked_plugin, | 128 bool RecordFlashUpdate(const base::FilePath& unpacked_plugin, |
129 const base::FilePath& moved_plugin, | 129 const base::FilePath& moved_plugin, |
130 const std::string& version) { | 130 const std::string& version) { |
131 base::MemoryMappedFile mapped_file; | 131 base::MemoryMappedFile mapped_file; |
132 if (!mapped_file.Initialize(unpacked_plugin)) | 132 if (!mapped_file.Initialize(unpacked_plugin)) |
133 return false; | 133 return false; |
134 | 134 |
135 std::string hash(crypto::kSHA256Length, 0); | 135 std::string hash(crypto::kSHA256Length, 0); |
136 SHA256Hash(mapped_file, string_as_array(&hash), hash.size()); | 136 SHA256Hash(mapped_file, base::string_as_array(&hash), hash.size()); |
137 | 137 |
138 return WriteToDisk(kCurrentHintFileVersion, | 138 return WriteToDisk(kCurrentHintFileVersion, |
139 crypto::SecureHash::Algorithm::SHA256, hash, moved_plugin, | 139 crypto::SecureHash::Algorithm::SHA256, hash, moved_plugin, |
140 version); | 140 version); |
141 } | 141 } |
142 | 142 |
143 bool DoesHintFileExist() { | 143 bool DoesHintFileExist() { |
144 base::FilePath hint_file_path; | 144 base::FilePath hint_file_path; |
145 if (!PathService::Get(chrome::FILE_COMPONENT_FLASH_HINT, &hint_file_path)) | 145 if (!PathService::Get(chrome::FILE_COMPONENT_FLASH_HINT, &hint_file_path)) |
146 return false; | 146 return false; |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
202 if (!base::Base64Decode(hash, &decoded_hash)) | 202 if (!base::Base64Decode(hash, &decoded_hash)) |
203 return false; | 203 return false; |
204 | 204 |
205 const base::FilePath plugin_path(plugin_path_str); | 205 const base::FilePath plugin_path(plugin_path_str); |
206 base::MemoryMappedFile plugin_file; | 206 base::MemoryMappedFile plugin_file; |
207 if (!plugin_file.Initialize(plugin_path)) | 207 if (!plugin_file.Initialize(plugin_path)) |
208 return false; | 208 return false; |
209 | 209 |
210 std::vector<uint8_t> file_hash(crypto::kSHA256Length, 0); | 210 std::vector<uint8_t> file_hash(crypto::kSHA256Length, 0); |
211 SHA256Hash(plugin_file, &file_hash[0], file_hash.size()); | 211 SHA256Hash(plugin_file, &file_hash[0], file_hash.size()); |
212 if (!crypto::SecureMemEqual(&file_hash[0], string_as_array(&decoded_hash), | 212 if (!crypto::SecureMemEqual(&file_hash[0], |
| 213 base::string_as_array(&decoded_hash), |
213 crypto::kSHA256Length)) { | 214 crypto::kSHA256Length)) { |
214 LOG(ERROR) | 215 LOG(ERROR) |
215 << "The hash recorded in the component flash hint file does not " | 216 << "The hash recorded in the component flash hint file does not " |
216 "match the actual hash of the flash plugin found on disk. The " | 217 "match the actual hash of the flash plugin found on disk. The " |
217 "component flash plugin will not be loaded."; | 218 "component flash plugin will not be loaded."; |
218 return false; | 219 return false; |
219 } | 220 } |
220 | 221 |
221 *path = plugin_path; | 222 *path = plugin_path; |
222 flash_version->assign(plugin_version_str); | 223 flash_version->assign(plugin_version_str); |
223 return true; | 224 return true; |
224 } | 225 } |
225 | 226 |
226 } // namespace component_flash_hint_file | 227 } // namespace component_flash_hint_file |
OLD | NEW |