diff options
author | Niall Douglas (s [underscore] sourceforge {at} nedprod [dot] com) <spamtrap@nedprod.com> | 2020-07-16 23:49:57 +0300 |
---|---|---|
committer | Niall Douglas (s [underscore] sourceforge {at} nedprod [dot] com) <spamtrap@nedprod.com> | 2020-07-16 23:49:57 +0300 |
commit | 751ce5021b4ad47258db1c8dc7c90ee9155a9211 (patch) | |
tree | 7f0cbac02c1bac6c1e9357198a3a20386cbf4f00 | |
parent | 6f926dc9e61c9f5231de03c851373c7112f27186 (diff) |
Trap passing a non-writable handle into file_handle::clone_extents_to().
-rw-r--r-- | include/llfio/v2.0/detail/impl/posix/file_handle.ipp | 4 | ||||
-rw-r--r-- | include/llfio/v2.0/detail/impl/windows/file_handle.ipp | 4 |
2 files changed, 8 insertions, 0 deletions
diff --git a/include/llfio/v2.0/detail/impl/posix/file_handle.ipp b/include/llfio/v2.0/detail/impl/posix/file_handle.ipp index bdc57f25..59175770 100644 --- a/include/llfio/v2.0/detail/impl/posix/file_handle.ipp +++ b/include/llfio/v2.0/detail/impl/posix/file_handle.ipp @@ -434,6 +434,10 @@ result<file_handle::extent_pair> file_handle::clone_extents_to(file_handle::exte try { LLFIO_LOG_FUNCTION_CALL(this); + if(!dest_.is_writable()) + { + return errc::bad_file_descriptor; + } OUTCOME_TRY(auto mycurrentlength, maximum_extent()); if(extent.offset == (extent_type) -1 && extent.length == (extent_type) -1) { diff --git a/include/llfio/v2.0/detail/impl/windows/file_handle.ipp b/include/llfio/v2.0/detail/impl/windows/file_handle.ipp index 55154f4b..b9137ce8 100644 --- a/include/llfio/v2.0/detail/impl/windows/file_handle.ipp +++ b/include/llfio/v2.0/detail/impl/windows/file_handle.ipp @@ -410,6 +410,10 @@ result<file_handle::extent_pair> file_handle::clone_extents_to(file_handle::exte windows_nt_kernel::init(); using namespace windows_nt_kernel; LLFIO_LOG_FUNCTION_CALL(this); + if(!dest_.is_writable()) + { + return errc::bad_file_descriptor; + } OUTCOME_TRY(auto mycurrentlength, maximum_extent()); if(extent.offset == (extent_type) -1 && extent.length == (extent_type) -1) { |