Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/windirstat/llfio.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNiall Douglas (s [underscore] sourceforge {at} nedprod [dot] com) <spamtrap@nedprod.com>2020-10-06 17:57:24 +0300
committerNiall Douglas (s [underscore] sourceforge {at} nedprod [dot] com) <spamtrap@nedprod.com>2020-10-06 17:57:24 +0300
commitb8dcd691aea2b40f6b29f15f3600dbbbca034a57 (patch)
tree3fcc1c2388fcc0d136cec8216f18f61a5941b492
parente52cc883d48207aa3e1e52ca22072bcda2f4ee6d (diff)
Fix UB in status code config of LLFIO, whereby there was a cast to an object of incorrect dynamic type.
-rw-r--r--cmake/QuickCppLibBootstrap.cmake18
-rw-r--r--include/llfio/v2.0/status_code.hpp31
2 files changed, 36 insertions, 13 deletions
diff --git a/cmake/QuickCppLibBootstrap.cmake b/cmake/QuickCppLibBootstrap.cmake
index 8efa0b26..0094ad4f 100644
--- a/cmake/QuickCppLibBootstrap.cmake
+++ b/cmake/QuickCppLibBootstrap.cmake
@@ -31,11 +31,18 @@ endforeach()
if(DEFINED quickcpplib_DIR)
find_package(quickcpplib QUIET CONFIG)
if(quickcpplib_FOUND)
- set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${quickcpplib_DIR}/cmakelib")
- set(CTEST_QUICKCPPLIB_SCRIPTS "${quickcpplib_DIR}/scripts")
- set(quickcpplib_done ON)
+ if(EXISTS "${quickcpplib_DIR}/share/cmakelib")
+ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${quickcpplib_DIR}/share/cmakelib")
+ set(CTEST_QUICKCPPLIB_SCRIPTS "${quickcpplib_DIR}/share/scripts")
+ set(quickcpplib_done ON)
+ elseif(EXISTS "${quickcpplib_DIR}/../../../share/cmakelib")
+ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${quickcpplib_DIR}/../../../share/cmakelib")
+ set(CTEST_QUICKCPPLIB_SCRIPTS "${quickcpplib_DIR}/../../../share/scripts")
+ set(quickcpplib_done ON)
+ endif()
endif()
endif()
+#message("*** ${CMAKE_MODULE_PATH}")
if(NOT quickcpplib_done)
# CMAKE_SOURCE_DIR is the very topmost parent cmake project
# CMAKE_CURRENT_SOURCE_DIR is the current cmake subproject
@@ -58,11 +65,6 @@ if(NOT quickcpplib_done)
if(CTEST_QUICKCPPLIB_CLONE_DIR)
if(NOT EXISTS "${CTEST_QUICKCPPLIB_CLONE_DIR}/repo/cmakelib")
file(MAKE_DIRECTORY "${CTEST_QUICKCPPLIB_CLONE_DIR}")
- find_package(quickcpplib QUIET CONFIG PATHS "${CTEST_QUICKCPPLIB_CLONE_DIR}/repo")
- if(quickcpplib_FOUND)
- endif()
- endif()
- if(NOT EXISTS "${CTEST_QUICKCPPLIB_CLONE_DIR}/repo/cmakelib")
message(STATUS "quickcpplib not found, cloning git repository and installing into ${CTEST_QUICKCPPLIB_CLONE_DIR} ...")
include(FindGit)
execute_process(COMMAND "${GIT_EXECUTABLE}" clone --recurse-submodules --depth 1 --jobs 8 --shallow-submodules "https://github.com/ned14/quickcpplib.git" repo
diff --git a/include/llfio/v2.0/status_code.hpp b/include/llfio/v2.0/status_code.hpp
index 78f2fdab..fee8421b 100644
--- a/include/llfio/v2.0/status_code.hpp
+++ b/include/llfio/v2.0/status_code.hpp
@@ -1,5 +1,5 @@
/* LLFIO error handling
-(C) 2018 Niall Douglas <http://www.nedproductions.biz/> (24 commits)
+(C) 2018-2020 Niall Douglas <http://www.nedproductions.biz/> (24 commits)
File Created: June 2018
@@ -176,6 +176,16 @@ public:
file_io_error_domain &operator=(file_io_error_domain &&) = default;
~file_io_error_domain() = default;
+#if __cplusplus < 201402L && !defined(_MSC_VER)
+ static inline const file_io_error_domain &get()
+ {
+ static file_io_error_domain v;
+ return v;
+ }
+#else
+ static inline constexpr const file_io_error_domain &get();
+#endif
+
protected:
virtual inline string_ref _do_message(const SYSTEM_ERROR2_NAMESPACE::status_code<void> &code) const noexcept override final
{
@@ -229,6 +239,13 @@ protected:
return atomic_refcounted_string_ref(p, ret.size());
}
};
+#if __cplusplus >= 201402L || defined(_MSC_VER)
+template <class BaseStatusCodeDomain> constexpr file_io_error_domain<BaseStatusCodeDomain> file_io_error_domain_inst = {};
+template <class BaseStatusCodeDomain> inline constexpr const file_io_error_domain<BaseStatusCodeDomain> &file_io_error_domain<BaseStatusCodeDomain>::get()
+{
+ return file_io_error_domain_inst<BaseStatusCodeDomain>;
+}
+#endif
namespace detail
{
@@ -304,9 +321,11 @@ namespace detail
{
inline std::ostream &operator<<(std::ostream &s, const file_io_error &v) { return s << "llfio::file_io_error(" << v.message().c_str() << ")"; }
} // namespace detail
-inline file_io_error error_from_exception(std::exception_ptr &&ep = std::current_exception(), SYSTEM_ERROR2_NAMESPACE::system_code not_matched = errc::resource_unavailable_try_again) noexcept
+inline file_io_error error_from_exception(std::exception_ptr &&ep = std::current_exception(),
+ SYSTEM_ERROR2_NAMESPACE::system_code not_matched = errc::resource_unavailable_try_again) noexcept
{
- return SYSTEM_ERROR2_NAMESPACE::system_code_from_exception(static_cast<std::exception_ptr &&>(ep), static_cast<SYSTEM_ERROR2_NAMESPACE::system_code &&>(not_matched));
+ return SYSTEM_ERROR2_NAMESPACE::system_code_from_exception(static_cast<std::exception_ptr &&>(ep),
+ static_cast<SYSTEM_ERROR2_NAMESPACE::system_code &&>(not_matched));
}
LLFIO_V2_NAMESPACE_END
@@ -408,7 +427,8 @@ public:
#endif
return {};
}
- //! Retrieve a descriptive message for this failure, possibly with paths and stack backtraces. Extra detail only appears if called from the same thread as where the failure occurred.
+ //! Retrieve a descriptive message for this failure, possibly with paths and stack backtraces. Extra detail only appears if called from the same thread as
+ //! where the failure occurred.
inline std::string message() const
{
std::string ret(ec.message());
@@ -539,7 +559,8 @@ inline void error_info::throw_exception() const
template <class T> using result = OUTCOME_V2_NAMESPACE::result<T, error_info>;
using OUTCOME_V2_NAMESPACE::failure;
using OUTCOME_V2_NAMESPACE::success;
-inline error_info error_from_exception(std::exception_ptr &&ep = std::current_exception(), std::error_code not_matched = std::make_error_code(std::errc::resource_unavailable_try_again)) noexcept
+inline error_info error_from_exception(std::exception_ptr &&ep = std::current_exception(),
+ std::error_code not_matched = std::make_error_code(std::errc::resource_unavailable_try_again)) noexcept
{
return error_info(OUTCOME_V2_NAMESPACE::error_from_exception(std::move(ep), not_matched));
}