summaryrefslogtreecommitdiffstats
path: root/chrome/browser/extensions/sandboxed_unpacker.cc
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/browser/extensions/sandboxed_unpacker.cc')
-rw-r--r--chrome/browser/extensions/sandboxed_unpacker.cc16
1 files changed, 9 insertions, 7 deletions
diff --git a/chrome/browser/extensions/sandboxed_unpacker.cc b/chrome/browser/extensions/sandboxed_unpacker.cc
index 6a9d6e1..6832bfd 100644
--- a/chrome/browser/extensions/sandboxed_unpacker.cc
+++ b/chrome/browser/extensions/sandboxed_unpacker.cc
@@ -16,6 +16,7 @@
#include "base/message_loop/message_loop.h"
#include "base/metrics/histogram.h"
#include "base/path_service.h"
+#include "base/safe_numerics.h"
#include "base/sequenced_task_runner.h"
#include "base/strings/utf_string_conversions.h"
#include "base/threading/sequenced_worker_pool.h"
@@ -130,7 +131,8 @@ bool VerifyJunctionFreeLocation(base::FilePath* temp_dir) {
// NormalizeFilePath requires a non-empty file, so write some data.
// If you change the exit points of this function please make sure all
// exit points delete this temp file!
- file_util::WriteFile(temp_file, ".", 1);
+ if (file_util::WriteFile(temp_file, ".", 1) != 1)
+ return false;
base::FilePath normalized_temp_file;
bool normalized =
@@ -623,8 +625,8 @@ DictionaryValue* SandboxedUnpacker::RewriteManifestFile(
base::FilePath manifest_path =
extension_root_.Append(kManifestFilename);
- if (!file_util::WriteFile(manifest_path,
- manifest_json.data(), manifest_json.size())) {
+ int size = base::checked_numeric_cast<int>(manifest_json.size());
+ if (file_util::WriteFile(manifest_path, manifest_json.data(), size) != size) {
// Error saving manifest.json.
ReportFailure(
ERROR_SAVING_MANIFEST_JSON,
@@ -736,7 +738,8 @@ bool SandboxedUnpacker::RewriteImageFiles(SkBitmap* install_icon) {
// Note: we're overwriting existing files that the utility process wrote,
// so we can be sure the directory exists.
const char* image_data_ptr = reinterpret_cast<const char*>(&image_data[0]);
- if (!file_util::WriteFile(path, image_data_ptr, image_data.size())) {
+ int size = base::checked_numeric_cast<int>(image_data.size());
+ if (file_util::WriteFile(path, image_data_ptr, size) != size) {
// Error saving theme image.
ReportFailure(
ERROR_SAVING_THEME_IMAGE,
@@ -803,9 +806,8 @@ bool SandboxedUnpacker::RewriteCatalogFiles() {
// Note: we're overwriting existing files that the utility process read,
// so we can be sure the directory exists.
- if (!file_util::WriteFile(path,
- catalog_json.c_str(),
- catalog_json.size())) {
+ int size = base::checked_numeric_cast<int>(catalog_json.size());
+ if (file_util::WriteFile(path, catalog_json.c_str(), size) != size) {
// Error saving catalog.
ReportFailure(
ERROR_SAVING_CATALOG,