OLD | NEW |
---|---|
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 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
137 if (net::FileURLToFilePath(url, &path)) | 137 if (net::FileURLToFilePath(url, &path)) |
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 if (current_path.ReferencesParent()) | |
148 return false; | |
piman
2012/11/19 17:56:05
TBH, without more context, this seems overly restr
| |
149 | |
147 FilePath last_path; | 150 FilePath last_path; |
148 while (current_path != last_path) { | 151 while (current_path != last_path) { |
149 if (file_permissions_.find(current_path) != file_permissions_.end()) | 152 if (file_permissions_.find(current_path) != file_permissions_.end()) |
150 return (file_permissions_[current_path] & permissions) == permissions; | 153 return (file_permissions_[current_path] & permissions) == permissions; |
151 last_path = current_path; | 154 last_path = current_path; |
152 current_path = current_path.DirName(); | 155 current_path = current_path.DirName(); |
153 } | 156 } |
154 | 157 |
155 return false; | 158 return false; |
156 } | 159 } |
(...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
623 int permission) { | 626 int permission) { |
624 base::AutoLock lock(lock_); | 627 base::AutoLock lock(lock_); |
625 | 628 |
626 SecurityStateMap::iterator state = security_state_.find(child_id); | 629 SecurityStateMap::iterator state = security_state_.find(child_id); |
627 if (state == security_state_.end()) | 630 if (state == security_state_.end()) |
628 return false; | 631 return false; |
629 return state->second->HasPermissionsForFileSystem(filesystem_id, permission); | 632 return state->second->HasPermissionsForFileSystem(filesystem_id, permission); |
630 } | 633 } |
631 | 634 |
632 } // namespace content | 635 } // namespace content |
OLD | NEW |