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

Side by Side Diff: chrome/browser/component_updater/component_unpacker.cc

Issue 7565002: Fix memory errors in ComponentUpdater::ComponentUpdater(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/component_updater/component_updater_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) 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/component_updater/component_unpacker.h" 5 #include "chrome/browser/component_updater/component_unpacker.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/file_util.h" 10 #include "base/file_util.h"
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 sizeof(extension_misc::kSignatureAlgorithm), 84 sizeof(extension_misc::kSignatureAlgorithm),
85 &signature[0], signature.size(), 85 &signature[0], signature.size(),
86 &key[0], key.size())) { 86 &key[0], key.size())) {
87 // Signature verification initialization failed. This is most likely 87 // Signature verification initialization failed. This is most likely
88 // caused by a public key in the wrong format (should encode algorithm). 88 // caused by a public key in the wrong format (should encode algorithm).
89 result_ = kWrongKeyFormat; 89 result_ = kWrongKeyFormat;
90 return; 90 return;
91 } 91 }
92 92
93 const size_t kBufSize = 8 * 1024; 93 const size_t kBufSize = 8 * 1024;
94 scoped_ptr<uint8> buf(new uint8[kBufSize]); 94 scoped_array<uint8> buf(new uint8[kBufSize]);
95 while ((len = fread(buf.get(), 1, kBufSize, crx_file)) > 0) 95 while ((len = fread(buf.get(), 1, kBufSize, crx_file)) > 0)
96 verifier.VerifyUpdate(buf.get(), len); 96 verifier.VerifyUpdate(buf.get(), len);
97 97
98 if (!verifier.VerifyFinal()) { 98 if (!verifier.VerifyFinal()) {
99 result_ = kSignatureMismatch; 99 result_ = kSignatureMismatch;
100 return; 100 return;
101 } 101 }
102 102
103 public_key_.swap(key); 103 public_key_.swap(key);
104 result_ = kValid; 104 result_ = kValid;
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 } 201 }
202 // Installation succesful. The directory is not our concern now. 202 // Installation succesful. The directory is not our concern now.
203 unpack_path_.clear(); 203 unpack_path_.clear();
204 } 204 }
205 205
206 ComponentUnpacker::~ComponentUnpacker() { 206 ComponentUnpacker::~ComponentUnpacker() {
207 if (!unpack_path_.empty()) { 207 if (!unpack_path_.empty()) {
208 file_util::Delete(unpack_path_, true); 208 file_util::Delete(unpack_path_, true);
209 } 209 }
210 } 210 }
211
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/component_updater/component_updater_service_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698