Commit Graph

15 Commits

Author SHA1 Message Date
Crypto City
2bd5de6049 disable statx, for static build compatibility 2022-12-31 11:32:20 +00:00
Andrey Semashev
36cf9aaf81 Updated protection of remove_all against CVE-2022-21658 on POSIX.
The previous implementation could still allow for following symlinks
while remove_all is running if a directory was replaced with a symlink
higher in the tree than remove_all is currently processing. This was
reported here:

https://github.com/boostorg/filesystem/issues/224#issuecomment-1183738097

The solution is to use POSIX.1-2008 *at APIs to prevent symlink resolution
higher in the directory tree while iterating over the subtree in remove_all.
This required updating the directory iterator construction interface so that
it is possible to pass the base directory fd and return fd of the directory
used by the iterator. This is done via platform-specific params that are
currently defined only for POSIX. Additionally, status, symlink_status and
remove were extended to accept the base directory fd as well.

Other systems, including Windows, remain vulnerable.

Related to https://github.com/boostorg/filesystem/issues/224.
2022-07-17 04:00:07 +03:00
Andrey Semashev
123fe5faa6 Disable statx syscall usage on Android prior to 11.0.
Even though the syscall number is defined in kernel headers, the syscall
is blacklisted by seccomp in runtime.

Note that Android 11 also introduces the libc wrapper for statx, so
effectively the library will always use the libc wrapper on Android.

Reported in https://github.com/boostorg/filesystem/issues/229.
2022-03-02 14:19:25 +03:00
Andrey Semashev
41d076ace5 Added protection for CVE-2022-21658 in remove_all on POSIX systems.
Another process could replace the directory being processed by remove_all
with a symlink after remove_all called symlink_status but before
it creates a directory iterator. As a result, remove_all would remove
the linked directory contents instead of removing the symlink.

On POSIX systems that support fdopendir and O_NOFOLLOW flag for open(2),
this can be prevented by opening the directory with O_NOFOLLOW before
iterating. This will fail if the directory was replaced with a symlink.

No protection on other systems.

Reported in https://github.com/boostorg/filesystem/issues/224.
2022-01-30 23:41:06 +03:00
Andrey Semashev
049e9aad94 Check that linking with bcrypt works in has_bcrypt config test.
This allows to succeed library compilation if BCrypt API is
available in headers but the library is not.
2021-10-26 20:23:04 +03:00
Andrey Semashev
9e5a3e231e Added a configure check for init_priority attribute.
Apparently, gcc does not support the attribute on Mac OS 11.4. Since
we can't tell if other systems aren't supported as well, it's better
to check with a configure check. As a side effect, this might add
support for more compilers.

Closes https://github.com/boostorg/filesystem/issues/199.
2021-07-14 18:12:47 +03:00
Andrey Semashev
2dda038306 Reworked function pointers use and definitions.
Instead of using atomic<> to access global function pointers, use raw
pointers and atomic_ref to access them safely in multi-threaded builds.
This allows to ensure constant initialization of the function pointers,
even in C++03. This also solves the problem of undefined dynamic
initialization order that we previously tried to solve with the
init_priority attribute. The attribute turns out to not work if the
pointers were raw pointers (in single-threaded builds). It is also
not supported by Intel Compiler and possibly other, which required
us to avoid using the function pointer for fill_random.

The resulting code should be simpler and more portable. In order to
check for C++20 std::atomic_ref availability, the older check for <atomic>
header was replaced with a check for std::atomic_ref. If not available,
we're using Boost.Atomic, as before.
2021-06-14 22:09:15 +03:00
Andrey Semashev
b27ad65326 Increased the minimum buffer size in read/write loop in copy_file.
Also, take into account the target filesystem block size, if available.
2021-05-19 00:22:31 +03:00
Andrey Semashev
c03249c375 Reformatted code for more consistent look and better readability. 2021-04-24 22:37:57 +03:00
Andrey Semashev
a031e4ffa9 Added creation_time operation.
The operation allows to query file creation time.

Implementation partially inspired by:

https://github.com/boostorg/filesystem/pull/134

Closes https://github.com/boostorg/filesystem/pull/134.
2020-08-21 01:32:04 +03:00
Andrey Semashev
db390391bb Restored auto-linking and Windows CE support.
Auto-linking can still be useful to users of MSVC and compatible
compilers on Windows, when the user links against static build of
Boost.Filesystem. This feature is marked deprecated though, so
it can be removed in the future, when the generated CMake config
files include information about third-party dependencies of Boost
libraries.

Additionally, restored support for linking against Windows CE-cpecific
coredll library. This platform is not tested though and therefore not
properly supported.

Closes https://github.com/boostorg/filesystem/issues/156.
2020-07-28 14:48:42 +03:00
Andrey Semashev
2bfb8c91e1 Corrected configure check for BCrypt API. 2020-06-05 14:17:09 +03:00
Andrey Semashev
427697ffcd Check for Cygwin when including Boost.WinAPI. 2020-06-05 12:11:56 +03:00
Andrey Semashev
5d1b14df51 Moved Windows lib linking to the Jamfile and added a config check for BCrypt.
This should improve support for Windows compilers that don't support
auto-linking.
2020-06-05 11:58:17 +03:00
Andrey Semashev
9252269160 Added configuration steps to detect modification time representation in stat.
This should improve compatibility with Mac OS X and other systems with
various representations of file times in struct stat.
2020-05-12 14:56:24 +03:00