aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJonathan Wakely <jwakely@redhat.com>2022-02-07 23:36:47 +0000
committerJonathan Wakely <jwakely@redhat.com>2022-02-08 13:31:05 +0000
commit5750952bec1e632d1f804f4a1bed2f74c0f3b189 (patch)
tree3af6c6536fccae1c06adad8f1de8694d554e6dc5 /gcc
parentdecde11183bdccc46587d6614b75f3d56a2f2e4a (diff)
downloadgcc-5750952bec1e632d1f804f4a1bed2f74c0f3b189.zip
gcc-5750952bec1e632d1f804f4a1bed2f74c0f3b189.tar.gz
gcc-5750952bec1e632d1f804f4a1bed2f74c0f3b189.tar.bz2
libstdc++: Fix filesystem::remove_all for Windows [PR104161]
The recursive_directory_iterator::__erase member was failing for Windows, because the entry._M_type value is always file_type::none (because _Dir_base::advance doesn't populate it for Windows) and top.unlink uses fs::remove which sets an error using the system_category. That meant that ec.value() was a Windows error code and not an errno value, so the comparisons to EPERM and EISDIR failed. Instead of depending on a specific Windows error code for attempting to remove a directory, just use directory_entry::refresh() to query the type first. This doesn't avoid the TOCTTOU races with directory symlinks, but we can't avoid them on Windows without openat and unlinkat, and creating symlinks requires admin privs on Windows anyway. This also fixes the fs::remove_all(const path&) overload, which was supposed to use the same logic as the other overload, but I forgot to change it before my previous commit. libstdc++-v3/ChangeLog: PR libstdc++/104161 * src/c++17/fs_dir.cc (fs::recursive_directory_iterator::__erase): [i_GLIBCXX_FILESYSTEM_IS_WINDOWS]: Refresh entry._M_type member, instead of checking for errno values indicating a directory. * src/c++17/fs_ops.cc (fs::remove_all(const path&)): Use similar logic to non-throwing overload. (fs::remove_all(const path&, error_code&)): Add comments. * src/filesystem/ops-common.h: Likewise.
Diffstat (limited to 'gcc')
0 files changed, 0 insertions, 0 deletions