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

Side by Side Diff: webkit/fileapi/file_system_file_util.cc

Issue 7085005: Disallow links from being seen by the extensions via the fileapi. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Comment fix. Created 9 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « base/file_util_posix.cc ('k') | 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 (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "webkit/fileapi/file_system_file_util.h" 5 #include "webkit/fileapi/file_system_file_util.h"
6 6
7 #include <stack> 7 #include <stack>
8 8
9 #include "base/file_util_proxy.h" 9 #include "base/file_util_proxy.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 return base::PLATFORM_FILE_OK; 73 return base::PLATFORM_FILE_OK;
74 } 74 }
75 75
76 PlatformFileError FileSystemFileUtil::GetFileInfo( 76 PlatformFileError FileSystemFileUtil::GetFileInfo(
77 FileSystemOperationContext* unused, 77 FileSystemOperationContext* unused,
78 const FilePath& file_path, 78 const FilePath& file_path,
79 base::PlatformFileInfo* file_info, 79 base::PlatformFileInfo* file_info,
80 FilePath* platform_file_path) { 80 FilePath* platform_file_path) {
81 if (!file_util::PathExists(file_path)) 81 if (!file_util::PathExists(file_path))
82 return base::PLATFORM_FILE_ERROR_NOT_FOUND; 82 return base::PLATFORM_FILE_ERROR_NOT_FOUND;
83 #if defined(OS_CHROMEOS)
84 // TODO(rkc): Fix this hack once we have refactored file_util to handle
85 // symlinks correctly. This check prevents handled extensions from accessing
86 // links
87 if (file_util::IsLink(file_path))
Evan Martin 2011/05/27 20:57:09 Can you make this function local to this file? Th
88 return base::PLATFORM_FILE_ERROR_NOT_FOUND;
89 #endif
83 if (!file_util::GetFileInfo(file_path, file_info)) 90 if (!file_util::GetFileInfo(file_path, file_info))
84 return base::PLATFORM_FILE_ERROR_FAILED; 91 return base::PLATFORM_FILE_ERROR_FAILED;
85 *platform_file_path = file_path; 92 *platform_file_path = file_path;
86 return base::PLATFORM_FILE_OK; 93 return base::PLATFORM_FILE_OK;
87 } 94 }
88 95
89 PlatformFileError FileSystemFileUtil::ReadDirectory( 96 PlatformFileError FileSystemFileUtil::ReadDirectory(
90 FileSystemOperationContext* unused, 97 FileSystemOperationContext* unused,
91 const FilePath& file_path, 98 const FilePath& file_path,
92 std::vector<base::FileUtilProxy::Entry>* entries) { 99 std::vector<base::FileUtilProxy::Entry>* entries) {
93 // TODO(kkanetkar): Implement directory read in multiple chunks. 100 // TODO(kkanetkar): Implement directory read in multiple chunks.
94 if (!file_util::DirectoryExists(file_path)) 101 if (!file_util::DirectoryExists(file_path))
95 return base::PLATFORM_FILE_ERROR_NOT_FOUND; 102 return base::PLATFORM_FILE_ERROR_NOT_FOUND;
96 103
97 file_util::FileEnumerator file_enum( 104 file_util::FileEnumerator file_enum(
98 file_path, false, static_cast<file_util::FileEnumerator::FILE_TYPE>( 105 file_path, false, static_cast<file_util::FileEnumerator::FILE_TYPE>(
99 file_util::FileEnumerator::FILES | 106 file_util::FileEnumerator::FILES |
100 file_util::FileEnumerator::DIRECTORIES)); 107 file_util::FileEnumerator::DIRECTORIES));
101 FilePath current; 108 FilePath current;
102 while (!(current = file_enum.Next()).empty()) { 109 while (!(current = file_enum.Next()).empty()) {
103 base::FileUtilProxy::Entry entry; 110 base::FileUtilProxy::Entry entry;
104 file_util::FileEnumerator::FindInfo info; 111 file_util::FileEnumerator::FindInfo info;
105 file_enum.GetFindInfo(&info); 112 file_enum.GetFindInfo(&info);
106 entry.is_directory = file_enum.IsDirectory(info); 113 entry.is_directory = file_enum.IsDirectory(info);
107 // This will just give the entry's name instead of entire path 114 // This will just give the entry's name instead of entire path
108 // if we use current.value(). 115 // if we use current.value().
109 entry.name = file_util::FileEnumerator::GetFilename(info).value(); 116 entry.name = file_util::FileEnumerator::GetFilename(info).value();
117 #if defined(OS_CHROMEOS)
118 // TODO(rkc): Fix this also once we've refactored file_util
119 // This currently just prevents a file from showing up at all
120 // if it's a link, hence preventing arbitary 'read' exploits
121 if (!file_util::IsLink(file_path.Append(entry.name)))
122 #endif
110 entries->push_back(entry); 123 entries->push_back(entry);
111 } 124 }
112 return base::PLATFORM_FILE_OK; 125 return base::PLATFORM_FILE_OK;
113 } 126 }
114 127
115 PlatformFileError FileSystemFileUtil::CreateDirectory( 128 PlatformFileError FileSystemFileUtil::CreateDirectory(
116 FileSystemOperationContext* unused, 129 FileSystemOperationContext* unused,
117 const FilePath& file_path, 130 const FilePath& file_path,
118 bool exclusive, 131 bool exclusive,
119 bool recursive) { 132 bool recursive) {
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after
445 FileSystemFileUtil::CreateFileEnumerator( 458 FileSystemFileUtil::CreateFileEnumerator(
446 FileSystemOperationContext* unused, 459 FileSystemOperationContext* unused,
447 const FilePath& root_path) { 460 const FilePath& root_path) {
448 return new FileSystemFileEnumerator( 461 return new FileSystemFileEnumerator(
449 root_path, true, static_cast<file_util::FileEnumerator::FILE_TYPE>( 462 root_path, true, static_cast<file_util::FileEnumerator::FILE_TYPE>(
450 file_util::FileEnumerator::FILES | 463 file_util::FileEnumerator::FILES |
451 file_util::FileEnumerator::DIRECTORIES)); 464 file_util::FileEnumerator::DIRECTORIES));
452 } 465 }
453 466
454 } // namespace fileapi 467 } // namespace fileapi
OLDNEW
« no previous file with comments | « base/file_util_posix.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698