Jean Guyomarc'h b5df8c5942 fix: TOCTOU race when creating directories
When create_directories() is called to create a chain of directories,
path components are created one by one. For each path component, ghc
checks if the directory exists. If not it attempts to create it. In
case of failure to create this directory, the function fails.

This behavior exhibits a TOCTOU (Time Of Check/Time Of Use) race when
different threads of execution (e.g. different processes) attempt to
create the same paths (or paths that contain a common hierarchy).
The following sequence of events between threads T1 and T2 illustrates
the issue:

  T1: checks path P exists: no. Will attempt to create P...
  T2: checks path P exists: no. Will attempt to create P...
  T1: creates P, no error
  T2: fails to create P: raises an error

It is not desirable for create_directories() to fail in this case. This
commit mirrors the GNU libstdc++ implementation of the c++ filesystem
library: if the creation of a directory fails, we will inspect the path
that should have been created as a directory. If it is indeed a
directory (another thread of execution created it for us), the error is
now reset and the function continues to iterate to the next path
component.
2019-11-06 15:09:52 +01:00
..
filesystem.hpp fix: TOCTOU race when creating directories 2019-11-06 15:09:52 +01:00
fs_fwd.hpp Added support for forwarding/implementation includes to enhance compile time and hide system headers. 2019-03-24 01:53:44 -07:00
fs_impl.hpp Added support for forwarding/implementation includes to enhance compile time and hide system headers. 2019-03-24 01:53:44 -07:00
fs_std_fwd.hpp refs #17, defaulting to value_type = wchar_t and string_type = std::wstring on Windows when using fs_std*.hpp helper header 2019-06-01 21:15:23 +02:00
fs_std_impl.hpp refs #17, defaulting to value_type = wchar_t and string_type = std::wstring on Windows when using fs_std*.hpp helper header 2019-06-01 21:15:23 +02:00
fs_std.hpp refs #17, defaulting to value_type = wchar_t and string_type = std::wstring on Windows when using fs_std*.hpp helper header 2019-06-01 21:15:23 +02:00