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

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

Issue 11416218: Merge 168692 - Apply missing kParentDirectory check (Closed) Base URL: svn://svn.chromium.org/chrome/branches/1312/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 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 return request_file_set_.find(path) != request_file_set_.end(); 138 return request_file_set_.find(path) != request_file_set_.end();
139 } 139 }
140 140
141 return false; // Unmentioned schemes are disallowed. 141 return false; // Unmentioned schemes are disallowed.
142 } 142 }
143 143
144 // Determine if the certain permissions have been granted to a file. 144 // Determine if the certain permissions have been granted to a file.
145 bool HasPermissionsForFile(const FilePath& file, int permissions) { 145 bool HasPermissionsForFile(const FilePath& file, int permissions) {
146 FilePath current_path = file.StripTrailingSeparators(); 146 FilePath current_path = file.StripTrailingSeparators();
147 FilePath last_path; 147 FilePath last_path;
148 int skip = 0;
148 while (current_path != last_path) { 149 while (current_path != last_path) {
149 if (file_permissions_.find(current_path) != file_permissions_.end()) 150 FilePath base_name = current_path.BaseName();
150 return (file_permissions_[current_path] & permissions) == permissions; 151 if (base_name.value() == FilePath::kParentDirectory) {
152 ++skip;
153 } else if (skip > 0) {
154 if (base_name.value() != FilePath::kCurrentDirectory)
155 --skip;
156 } else {
157 if (file_permissions_.find(current_path) != file_permissions_.end())
158 return (file_permissions_[current_path] & permissions) == permissions;
159 }
151 last_path = current_path; 160 last_path = current_path;
152 current_path = current_path.DirName(); 161 current_path = current_path.DirName();
153 } 162 }
154 163
155 return false; 164 return false;
156 } 165 }
157 166
158 bool CanUseCookiesForOrigin(const GURL& gurl) { 167 bool CanUseCookiesForOrigin(const GURL& gurl) {
159 if (origin_lock_.is_empty()) 168 if (origin_lock_.is_empty())
160 return true; 169 return true;
(...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after
623 int permission) { 632 int permission) {
624 base::AutoLock lock(lock_); 633 base::AutoLock lock(lock_);
625 634
626 SecurityStateMap::iterator state = security_state_.find(child_id); 635 SecurityStateMap::iterator state = security_state_.find(child_id);
627 if (state == security_state_.end()) 636 if (state == security_state_.end())
628 return false; 637 return false;
629 return state->second->HasPermissionsForFileSystem(filesystem_id, permission); 638 return state->second->HasPermissionsForFileSystem(filesystem_id, permission);
630 } 639 }
631 640
632 } // namespace content 641 } // namespace content
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