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

Unified Diff: extensions/browser/content_hash_reader.cc

Issue 2771953003: Fix content verification code for undreadable and deleted files. (Closed)
Patch Set: address comments change DCHECK Created 3 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « extensions/browser/content_hash_reader.h ('k') | extensions/browser/content_verify_job.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: extensions/browser/content_hash_reader.cc
diff --git a/extensions/browser/content_hash_reader.cc b/extensions/browser/content_hash_reader.cc
index c7a99c04b028d3d12dac7dbf1fe59f583a7d82c9..039fa53e9b3ab33bb6df447489d5ac497920af4b 100644
--- a/extensions/browser/content_hash_reader.cc
+++ b/extensions/browser/content_hash_reader.cc
@@ -35,11 +35,10 @@ ContentHashReader::ContentHashReader(const std::string& extension_id,
relative_path_(relative_path),
key_(key),
status_(NOT_INITIALIZED),
- content_exists_(false),
have_verified_contents_(false),
have_computed_hashes_(false),
- block_size_(0) {
-}
+ file_missing_from_verified_contents_(false),
+ block_size_(0) {}
ContentHashReader::~ContentHashReader() {
}
@@ -50,14 +49,6 @@ bool ContentHashReader::Init() {
status_ = FAILURE;
base::FilePath verified_contents_path =
file_util::GetVerifiedContentsPath(extension_root_);
-
- // Check that this is a valid resource to verify (i.e., it exists).
- base::FilePath content_path = extension_root_.Append(relative_path_);
- if (!base::PathExists(content_path) || base::DirectoryExists(content_path))
- return false;
-
- content_exists_ = true;
-
if (!base::PathExists(verified_contents_path))
return false;
@@ -82,6 +73,15 @@ bool ContentHashReader::Init() {
have_computed_hashes_ = true;
+ if (!verified_contents.HasTreeHashRoot(relative_path_)) {
+ // Extension is requesting a non-existent resource that does not have an
+ // entry in verified_contents.json. This can happen when an extension sends
+ // XHR to its non-existent resource. This should not result in content
+ // verification failure.
+ file_missing_from_verified_contents_ = true;
+ return false;
+ }
+
if (!reader.GetHashes(relative_path_, &block_size_, &hashes_) ||
block_size_ % crypto::kSHA256Length != 0)
return false;
« no previous file with comments | « extensions/browser/content_hash_reader.h ('k') | extensions/browser/content_verify_job.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698