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

Side by Side Diff: content/browser/child_process_security_policy_impl.cc

Issue 11316208: Merge 168692 - Apply missing kParentDirectory check (Closed) Base URL: svn://svn.chromium.org/chrome/branches/1271/src/
Patch Set: Created 8 years 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 | content/browser/child_process_security_policy_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 "content/browser/child_process_security_policy_impl.h" 5 #include "content/browser/child_process_security_policy_impl.h"
6 6
7 #include "base/file_path.h" 7 #include "base/file_path.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/metrics/histogram.h" 9 #include "base/metrics/histogram.h"
10 #include "base/platform_file.h" 10 #include "base/platform_file.h"
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 return request_file_set_.find(path) != request_file_set_.end(); 139 return request_file_set_.find(path) != request_file_set_.end();
140 } 140 }
141 141
142 return false; // Unmentioned schemes are disallowed. 142 return false; // Unmentioned schemes are disallowed.
143 } 143 }
144 144
145 // Determine if the certain permissions have been granted to a file. 145 // Determine if the certain permissions have been granted to a file.
146 bool HasPermissionsForFile(const FilePath& file, int permissions) { 146 bool HasPermissionsForFile(const FilePath& file, int permissions) {
147 FilePath current_path = file.StripTrailingSeparators(); 147 FilePath current_path = file.StripTrailingSeparators();
148 FilePath last_path; 148 FilePath last_path;
149 int skip = 0;
149 while (current_path != last_path) { 150 while (current_path != last_path) {
150 if (file_permissions_.find(current_path) != file_permissions_.end()) 151 FilePath base_name = current_path.BaseName();
151 return (file_permissions_[current_path] & permissions) == permissions; 152 if (base_name.value() == FilePath::kParentDirectory) {
153 ++skip;
154 } else if (skip > 0) {
155 if (base_name.value() != FilePath::kCurrentDirectory)
156 --skip;
157 } else {
158 if (file_permissions_.find(current_path) != file_permissions_.end())
159 return (file_permissions_[current_path] & permissions) == permissions;
160 }
152 last_path = current_path; 161 last_path = current_path;
153 current_path = current_path.DirName(); 162 current_path = current_path.DirName();
154 } 163 }
155 164
156 return false; 165 return false;
157 } 166 }
158 167
159 bool CanUseCookiesForOrigin(const GURL& gurl) { 168 bool CanUseCookiesForOrigin(const GURL& gurl) {
160 if (origin_lock_.is_empty()) 169 if (origin_lock_.is_empty())
161 return true; 170 return true;
(...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after
622 int child_id, 631 int child_id,
623 const std::string& filesystem_id, 632 const std::string& filesystem_id,
624 int permission) { 633 int permission) {
625 base::AutoLock lock(lock_); 634 base::AutoLock lock(lock_);
626 635
627 SecurityStateMap::iterator state = security_state_.find(child_id); 636 SecurityStateMap::iterator state = security_state_.find(child_id);
628 if (state == security_state_.end()) 637 if (state == security_state_.end())
629 return false; 638 return false;
630 return state->second->HasPermissionsForFileSystem(filesystem_id, permission); 639 return state->second->HasPermissionsForFileSystem(filesystem_id, permission);
631 } 640 }
OLDNEW
« no previous file with comments | « no previous file | content/browser/child_process_security_policy_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698