Skip to content

Commit

Permalink
Merge pull request #34 from jeanguyomarch/toctou-race
Browse files Browse the repository at this point in the history
fix: TOCTOU race when creating directories
  • Loading branch information
gulrak committed Nov 6, 2019
2 parents 9db85fa + b5df8c5 commit 741eaca
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion include/ghc/filesystem.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3391,7 +3391,12 @@ GHC_INLINE bool create_directories(const path& p, std::error_code& ec) noexcept
if (!exists(fs)) {
create_directory(current, ec);
if (ec) {
return false;
std::error_code tmp_ec;
if (is_directory(current, tmp_ec)) {
ec.clear();
} else {
return false;
}
}
}
#ifndef LWG_2935_BEHAVIOUR
Expand Down

0 comments on commit 741eaca

Please sign in to comment.