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

Unified Diff: base/file_util.h

Issue 12223014: Add path traversal protection to Move and CopyFile too. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 7 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | base/file_util.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/file_util.h
===================================================================
--- base/file_util.h (revision 180593)
+++ base/file_util.h (working copy)
@@ -120,9 +120,15 @@
// If a simple rename is not possible, such as in the case where the paths are
// on different volumes, this will attempt to copy and delete. Returns
// true for success.
+// This function fails if either path contains traversal components ('..').
BASE_EXPORT bool Move(const base::FilePath& from_path,
const base::FilePath& to_path);
+// Same as Move but allows paths with traversal components.
+// Use only with extreme care.
+BASE_EXPORT bool MoveUnsafe(const base::FilePath& from_path,
+ const base::FilePath& to_path);
+
// Renames file |from_path| to |to_path|. Both paths must be on the same
// volume, or the function will fail. Destination file will be created
// if it doesn't exist. Prefer this function over Move when dealing with
@@ -132,9 +138,15 @@
const base::FilePath& to_path);
// Copies a single file. Use CopyDirectory to copy directories.
+// This function fails if either path contains traversal components ('..').
BASE_EXPORT bool CopyFile(const base::FilePath& from_path,
const base::FilePath& to_path);
+// Same as CopyFile but allows paths with traversal components.
+// Use only with extreme care.
+BASE_EXPORT bool CopyFileUnsafe(const base::FilePath& from_path,
+ const base::FilePath& to_path);
+
// Copies the given path, and optionally all subdirectories and their contents
// as well.
// If there are files existing under to_path, always overwrite.
« no previous file with comments | « no previous file | base/file_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698