diff options
author | skerner@chromium.org <skerner@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-06-09 22:56:48 +0000 |
---|---|---|
committer | skerner@chromium.org <skerner@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-06-09 22:56:48 +0000 |
commit | 6f5f4322d6688abd29d0253a6a8201fb7b1c103d (patch) | |
tree | 1ceb35e4715990b18b9f7f6327c5072f7a699fe4 /base/file_util_posix.cc | |
parent | a53bb6f7db58fa59fb2dd3b6508b6acc0d1d44ad (diff) | |
download | chromium_src-6f5f4322d6688abd29d0253a6a8201fb7b1c103d.zip chromium_src-6f5f4322d6688abd29d0253a6a8201fb7b1c103d.tar.gz chromium_src-6f5f4322d6688abd29d0253a6a8201fb7b1c103d.tar.bz2 |
Give the extension unpacker process a junction/symlink free path to the unpack directory.
BUG=35198,13044
TEST=FileUtilTest.NormalizeFilePathBasic,FileUtilTest. NormalizeFilePathReparsePoints,FileUtilTest.NormalizeFilePathSymlinks
Review URL: http://codereview.chromium.org/2088006
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@49337 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/file_util_posix.cc')
-rw-r--r-- | base/file_util_posix.cc | 29 |
1 files changed, 25 insertions, 4 deletions
diff --git a/base/file_util_posix.cc b/base/file_util_posix.cc index bd1711b..441ecc8 100644 --- a/base/file_util_posix.cc +++ b/base/file_util_posix.cc @@ -44,6 +44,20 @@ namespace file_util { +namespace { + +// Helper for NormalizeFilePath(), defined below. +bool RealPath(const FilePath& path, FilePath* real_path) { + FilePath::CharType buf[PATH_MAX]; + if (!realpath(path.value().c_str(), buf)) + return false; + + *real_path = FilePath(buf); + return true; +} + +} // namespace + #if defined(OS_OPENBSD) || defined(OS_FREEBSD) || \ (defined(OS_MACOSX) && \ MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_5) @@ -726,12 +740,19 @@ bool HasFileBeenModifiedSince(const FileEnumerator::FindInfo& find_info, return find_info.stat.st_mtime >= cutoff_time.ToTimeT(); } -bool RealPath(const FilePath& path, FilePath* real_path) { - FilePath::CharType buf[PATH_MAX]; - if (!realpath(path.value().c_str(), buf)) +bool NormalizeFilePath(const FilePath& path, FilePath* normalized_path) { + FilePath real_path_result; + if (!RealPath(path, &real_path_result)) return false; - *real_path = FilePath(buf); + // To be consistant with windows, fail if |real_path_result| is a + // directory. + stat_wrapper_t file_info; + if (CallStat(real_path_result.value().c_str(), &file_info) != 0 || + S_ISDIR(file_info.st_mode)) + return false; + + *normalized_path = real_path_result; return true; } |