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 "base/path_service.h" | 5 #include "base/path_service.h" |
6 | 6 |
7 #ifdef OS_WIN | 7 #ifdef OS_WIN |
8 #include <windows.h> | 8 #include <windows.h> |
9 #include <shellapi.h> | 9 #include <shellapi.h> |
10 #include <shlobj.h> | 10 #include <shlobj.h> |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
202 while (provider) { | 202 while (provider) { |
203 if (provider->func(key, &path)) | 203 if (provider->func(key, &path)) |
204 break; | 204 break; |
205 DCHECK(path.empty()) << "provider should not have modified path"; | 205 DCHECK(path.empty()) << "provider should not have modified path"; |
206 provider = provider->next; | 206 provider = provider->next; |
207 } | 207 } |
208 | 208 |
209 if (path.empty()) | 209 if (path.empty()) |
210 return false; | 210 return false; |
211 | 211 |
| 212 if (path.ReferencesParent()) { |
| 213 // Make sure path service never returns a path with ".." in it. |
| 214 if (!file_util::AbsolutePath(&path)) { |
| 215 return false; |
| 216 } |
| 217 } |
212 *result = path; | 218 *result = path; |
213 | 219 |
214 base::AutoLock scoped_lock(path_data->lock); | 220 base::AutoLock scoped_lock(path_data->lock); |
215 path_data->cache[key] = path; | 221 path_data->cache[key] = path; |
216 | 222 |
217 return true; | 223 return true; |
218 } | 224 } |
219 | 225 |
220 // static | 226 // static |
221 bool PathService::Override(int key, const FilePath& path) { | 227 bool PathService::Override(int key, const FilePath& path) { |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
304 while (iter) { | 310 while (iter) { |
305 DCHECK(key_start >= iter->key_end || key_end <= iter->key_start) << | 311 DCHECK(key_start >= iter->key_end || key_end <= iter->key_start) << |
306 "path provider collision"; | 312 "path provider collision"; |
307 iter = iter->next; | 313 iter = iter->next; |
308 } | 314 } |
309 #endif | 315 #endif |
310 | 316 |
311 p->next = path_data->providers; | 317 p->next = path_data->providers; |
312 path_data->providers = p; | 318 path_data->providers = p; |
313 } | 319 } |
OLD | NEW |