mirror of
https://git.mirrors.martin98.com/https://github.com/gulrak/filesystem
synced 2025-06-04 11:13:58 +08:00
Merge pull request #34 from jeanguyomarch/toctou-race
fix: TOCTOU race when creating directories
This commit is contained in:
commit
741eaca3fd
@ -3391,9 +3391,14 @@ GHC_INLINE bool create_directories(const path& p, std::error_code& ec) noexcept
|
|||||||
if (!exists(fs)) {
|
if (!exists(fs)) {
|
||||||
create_directory(current, ec);
|
create_directory(current, ec);
|
||||||
if (ec) {
|
if (ec) {
|
||||||
|
std::error_code tmp_ec;
|
||||||
|
if (is_directory(current, tmp_ec)) {
|
||||||
|
ec.clear();
|
||||||
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
#ifndef LWG_2935_BEHAVIOUR
|
#ifndef LWG_2935_BEHAVIOUR
|
||||||
else if (!is_directory(fs)) {
|
else if (!is_directory(fs)) {
|
||||||
ec = detail::make_error_code(detail::portable_error::exists);
|
ec = detail::make_error_code(detail::portable_error::exists);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user