diff options
author | yoshiki@chromium.org <yoshiki@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-06-30 05:26:59 +0000 |
---|---|---|
committer | yoshiki@chromium.org <yoshiki@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-06-30 05:26:59 +0000 |
commit | 7122db29d3965050505f7294f073d83f80ea7835 (patch) | |
tree | 57f9b83338a210b1ad7bdac8038854fc7f25cc16 /base/file_util_posix.cc | |
parent | 4dec5802baac225df48fb9153d2af7621d5850e6 (diff) | |
download | chromium_src-7122db29d3965050505f7294f073d83f80ea7835.zip chromium_src-7122db29d3965050505f7294f073d83f80ea7835.tar.gz chromium_src-7122db29d3965050505f7294f073d83f80ea7835.tar.bz2 |
Fix a bug in file_util::Delete() where symlinks are not handled right
With this patch, file_util::Delete() uses lstat64() instead of stat64(), so that Delete() checks the existence of the symbolic link itself not a file pointed by the symlink. This allows us to delete a symbolic link when it points to a non-existent file.
BUG=119430
TEST=base_unittests::FileUtilTest.* passes.
Review URL: https://chromiumcodereview.appspot.com/10690047
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@145060 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/file_util_posix.cc')
-rw-r--r-- | base/file_util_posix.cc | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/base/file_util_posix.cc b/base/file_util_posix.cc index c9a0d9b..e3bab95 100644 --- a/base/file_util_posix.cc +++ b/base/file_util_posix.cc @@ -207,7 +207,7 @@ bool Delete(const FilePath& path, bool recursive) { base::ThreadRestrictions::AssertIOAllowed(); const char* path_str = path.value().c_str(); stat_wrapper_t file_info; - int test = CallStat(path_str, &file_info); + int test = CallLstat(path_str, &file_info); if (test != 0) { // The Windows version defines this condition as success. bool ret = (errno == ENOENT || errno == ENOTDIR); @@ -578,10 +578,10 @@ bool CreateDirectory(const FilePath& full_path) { // TODO(rkc): Refactor GetFileInfo and FileEnumerator to handle symlinks // correctly. http://code.google.com/p/chromium-os/issues/detail?id=15948 bool IsLink(const FilePath& file_path) { - struct stat st; + stat_wrapper_t st; // If we can't lstat the file, it's safe to assume that the file won't at // least be a 'followable' link. - if (lstat(file_path.value().c_str(), &st) != 0) + if (CallLstat(file_path.value().c_str(), &st) != 0) return false; if (S_ISLNK(st.st_mode)) |