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

Side by Side Diff: chrome/browser/extensions/extension_creator.cc

Issue 20794003: Fix a bug where packing an extension with bad private key causes crash. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Slight wording change to the pack_extension_unittest. Created 7 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 unified diff | Download patch
« no previous file with comments | « no previous file | chrome/browser/extensions/extension_service_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/extensions/extension_creator.h" 5 #include "chrome/browser/extensions/extension_creator.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 while ((bytes_read = fread(buffer.get(), 1, buffer_size, 221 while ((bytes_read = fread(buffer.get(), 1, buffer_size,
222 zip_handle.get())) > 0) { 222 zip_handle.get())) > 0) {
223 if (!signature_creator->Update(buffer.get(), bytes_read)) { 223 if (!signature_creator->Update(buffer.get(), bytes_read)) {
224 error_message_ = 224 error_message_ =
225 l10n_util::GetStringUTF8(IDS_EXTENSION_ERROR_WHILE_SIGNING); 225 l10n_util::GetStringUTF8(IDS_EXTENSION_ERROR_WHILE_SIGNING);
226 return false; 226 return false;
227 } 227 }
228 } 228 }
229 zip_handle.Close(); 229 zip_handle.Close();
230 230
231 signature_creator->Final(signature); 231 if (!signature_creator->Final(signature)) {
232 error_message_ =
233 l10n_util::GetStringUTF8(IDS_EXTENSION_ERROR_WHILE_SIGNING);
234 return false;
235 }
232 return true; 236 return true;
233 } 237 }
234 238
235 bool ExtensionCreator::WriteCRX(const base::FilePath& zip_path, 239 bool ExtensionCreator::WriteCRX(const base::FilePath& zip_path,
236 crypto::RSAPrivateKey* private_key, 240 crypto::RSAPrivateKey* private_key,
237 const std::vector<uint8>& signature, 241 const std::vector<uint8>& signature,
238 const base::FilePath& crx_path) { 242 const base::FilePath& crx_path) {
239 if (base::PathExists(crx_path)) 243 if (base::PathExists(crx_path))
240 base::DeleteFile(crx_path, false); 244 base::DeleteFile(crx_path, false);
241 ScopedStdioHandle crx_handle(file_util::OpenFile(crx_path, "wb")); 245 ScopedStdioHandle crx_handle(file_util::OpenFile(crx_path, "wb"));
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
320 SignZip(zip_path, key_pair.get(), &signature) && 324 SignZip(zip_path, key_pair.get(), &signature) &&
321 WriteCRX(zip_path, key_pair.get(), signature, crx_path)) { 325 WriteCRX(zip_path, key_pair.get(), signature, crx_path)) {
322 result = true; 326 result = true;
323 } 327 }
324 328
325 base::DeleteFile(zip_path, false); 329 base::DeleteFile(zip_path, false);
326 return result; 330 return result;
327 } 331 }
328 332
329 } // namespace extensions 333 } // namespace extensions
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/extensions/extension_service_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698