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

Side by Side Diff: base/platform_file.h

Issue 11782005: Don't allow path traversal paths on the base file helpers (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 7 years, 11 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
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 #ifndef BASE_PLATFORM_FILE_H_ 5 #ifndef BASE_PLATFORM_FILE_H_
6 #define BASE_PLATFORM_FILE_H_ 6 #define BASE_PLATFORM_FILE_H_
7 7
8 #include "build/build_config.h" 8 #include "build/build_config.h"
9 #if defined(OS_WIN) 9 #if defined(OS_WIN)
10 #include <windows.h> 10 #include <windows.h>
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 base::Time last_accessed; 113 base::Time last_accessed;
114 114
115 // The creation time of a file. 115 // The creation time of a file.
116 base::Time creation_time; 116 base::Time creation_time;
117 }; 117 };
118 118
119 // Creates or opens the given file. If |created| is provided, it will be set to 119 // Creates or opens the given file. If |created| is provided, it will be set to
120 // true if a new file was created [or an old one truncated to zero length to 120 // true if a new file was created [or an old one truncated to zero length to
121 // simulate a new file, which can happen with PLATFORM_FILE_CREATE_ALWAYS], and 121 // simulate a new file, which can happen with PLATFORM_FILE_CREATE_ALWAYS], and
122 // false otherwise. |error_code| can be NULL. 122 // false otherwise. |error_code| can be NULL.
123 //
124 // This function fails with 'access denied' if the |name| contains path
125 // traversal components.
123 BASE_EXPORT PlatformFile CreatePlatformFile(const FilePath& name, 126 BASE_EXPORT PlatformFile CreatePlatformFile(const FilePath& name,
124 int flags, 127 int flags,
125 bool* created, 128 bool* created,
126 PlatformFileError* error_code); 129 PlatformFileError* error_code);
127 130
131 // Same as CreatePlatformFile but allows paths with traversal (like \..\)
132 // components. Use only with extreme care.
133 BASE_EXPORT PlatformFile CreatePlatformFileAllowTraversal(
134 const FilePath& name, int flags, bool* created,
brettw 2013/01/07 20:50:26 Can you horizontally align the params on different
135 PlatformFileError* error_code);
136
128 // Closes a file handle. Returns |true| on success and |false| otherwise. 137 // Closes a file handle. Returns |true| on success and |false| otherwise.
129 BASE_EXPORT bool ClosePlatformFile(PlatformFile file); 138 BASE_EXPORT bool ClosePlatformFile(PlatformFile file);
130 139
131 // Changes current position in the file to an |offset| relative to an origin 140 // Changes current position in the file to an |offset| relative to an origin
132 // defined by |whence|. Returns the resultant current position in the file 141 // defined by |whence|. Returns the resultant current position in the file
133 // (relative to the start) or -1 in case of error. 142 // (relative to the start) or -1 in case of error.
134 BASE_EXPORT int64 SeekPlatformFile(PlatformFile file, 143 BASE_EXPORT int64 SeekPlatformFile(PlatformFile file,
135 PlatformFileWhence whence, 144 PlatformFileWhence whence,
136 int64 offset); 145 int64 offset);
137 146
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 return temp; 232 return temp;
224 } 233 }
225 234
226 private: 235 private:
227 PlatformFile* value_; 236 PlatformFile* value_;
228 }; 237 };
229 238
230 } // namespace base 239 } // namespace base
231 240
232 #endif // BASE_PLATFORM_FILE_H_ 241 #endif // BASE_PLATFORM_FILE_H_
OLDNEW
« base/file_util.cc ('K') | « base/file_util.cc ('k') | base/platform_file.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698