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

Side by Side Diff: extensions/browser/content_hash_reader.cc

Issue 1105493002: Accessing directories in extensions should not cause content verifier failure. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 8 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 | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "extensions/browser/content_hash_reader.h" 5 #include "extensions/browser/content_hash_reader.h"
6 6
7 #include "base/base64.h" 7 #include "base/base64.h"
8 #include "base/files/file_util.h" 8 #include "base/files/file_util.h"
9 #include "base/json/json_reader.h" 9 #include "base/json/json_reader.h"
10 #include "base/metrics/histogram.h" 10 #include "base/metrics/histogram.h"
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 46
47 bool ContentHashReader::Init() { 47 bool ContentHashReader::Init() {
48 base::ElapsedTimer timer; 48 base::ElapsedTimer timer;
49 DCHECK_EQ(status_, NOT_INITIALIZED); 49 DCHECK_EQ(status_, NOT_INITIALIZED);
50 status_ = FAILURE; 50 status_ = FAILURE;
51 base::FilePath verified_contents_path = 51 base::FilePath verified_contents_path =
52 file_util::GetVerifiedContentsPath(extension_root_); 52 file_util::GetVerifiedContentsPath(extension_root_);
53 53
54 // Check that this is a valid resource to verify (i.e., it exists). 54 // Check that this is a valid resource to verify (i.e., it exists).
55 base::FilePath content_path = extension_root_.Append(relative_path_); 55 base::FilePath content_path = extension_root_.Append(relative_path_);
56 if (!base::PathExists(content_path)) 56 if (!base::PathExists(content_path) || base::DirectoryExists(content_path))
57 return false; 57 return false;
58 58
59 content_exists_ = true; 59 content_exists_ = true;
60 60
61 if (!base::PathExists(verified_contents_path)) 61 if (!base::PathExists(verified_contents_path))
62 return false; 62 return false;
63 63
64 verified_contents_.reset(new VerifiedContents(key_.data, key_.size)); 64 verified_contents_.reset(new VerifiedContents(key_.data, key_.size));
65 if (!verified_contents_->InitFrom(verified_contents_path, false) || 65 if (!verified_contents_->InitFrom(verified_contents_path, false) ||
66 !verified_contents_->valid_signature() || 66 !verified_contents_->valid_signature() ||
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 DCHECK(block_index >= 0); 113 DCHECK(block_index >= 0);
114 114
115 if (static_cast<unsigned>(block_index) >= hashes_.size()) 115 if (static_cast<unsigned>(block_index) >= hashes_.size())
116 return false; 116 return false;
117 *result = &hashes_[block_index]; 117 *result = &hashes_[block_index];
118 118
119 return true; 119 return true;
120 } 120 }
121 121
122 } // namespace extensions 122 } // namespace extensions
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698