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

Side by Side Diff: base/platform_file_posix.cc

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 #include "base/platform_file.h" 5 #include "base/platform_file.h"
6 6
7 #include <fcntl.h> 7 #include <fcntl.h>
8 #include <errno.h> 8 #include <errno.h>
9 #include <sys/stat.h> 9 #include <sys/stat.h>
10 #include <unistd.h> 10 #include <unistd.h>
(...skipping 23 matching lines...) Expand all
34 } 34 }
35 #else 35 #else
36 typedef struct stat64 stat_wrapper_t; 36 typedef struct stat64 stat_wrapper_t;
37 static int CallFstat(int fd, stat_wrapper_t *sb) { 37 static int CallFstat(int fd, stat_wrapper_t *sb) {
38 base::ThreadRestrictions::AssertIOAllowed(); 38 base::ThreadRestrictions::AssertIOAllowed();
39 return fstat64(fd, sb); 39 return fstat64(fd, sb);
40 } 40 }
41 #endif 41 #endif
42 42
43 // TODO(erikkay): does it make sense to support PLATFORM_FILE_EXCLUSIVE_* here? 43 // TODO(erikkay): does it make sense to support PLATFORM_FILE_EXCLUSIVE_* here?
44 PlatformFile CreatePlatformFile(const FilePath& name, int flags, 44 PlatformFile CreatePlatformFileAllowTraversal(const FilePath& name,
45 bool* created, PlatformFileError* error_code) { 45 int flags,
46 bool* created,
47 PlatformFileError* error_code) {
46 base::ThreadRestrictions::AssertIOAllowed(); 48 base::ThreadRestrictions::AssertIOAllowed();
47 49
48 int open_flags = 0; 50 int open_flags = 0;
49 if (flags & PLATFORM_FILE_CREATE) 51 if (flags & PLATFORM_FILE_CREATE)
50 open_flags = O_CREAT | O_EXCL; 52 open_flags = O_CREAT | O_EXCL;
51 53
52 if (created) 54 if (created)
53 *created = false; 55 *created = false;
54 56
55 if (flags & PLATFORM_FILE_CREATE_ALWAYS) { 57 if (flags & PLATFORM_FILE_CREATE_ALWAYS) {
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
309 info->is_directory = S_ISDIR(file_info.st_mode); 311 info->is_directory = S_ISDIR(file_info.st_mode);
310 info->is_symbolic_link = S_ISLNK(file_info.st_mode); 312 info->is_symbolic_link = S_ISLNK(file_info.st_mode);
311 info->size = file_info.st_size; 313 info->size = file_info.st_size;
312 info->last_modified = base::Time::FromTimeT(file_info.st_mtime); 314 info->last_modified = base::Time::FromTimeT(file_info.st_mtime);
313 info->last_accessed = base::Time::FromTimeT(file_info.st_atime); 315 info->last_accessed = base::Time::FromTimeT(file_info.st_atime);
314 info->creation_time = base::Time::FromTimeT(file_info.st_ctime); 316 info->creation_time = base::Time::FromTimeT(file_info.st_ctime);
315 return true; 317 return true;
316 } 318 }
317 319
318 } // namespace base 320 } // namespace base
OLDNEW
« base/platform_file.h ('K') | « base/platform_file.cc ('k') | base/platform_file_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698