Skip to content

Commit

Permalink
Merge pull request cppfastio#861 from trcrsired/master
Browse files Browse the repository at this point in the history
remove check on os_c_str_null_terminated since it may contain TOCTOU
  • Loading branch information
trcrsired authored Sep 30, 2024
2 parents 5f3bc69 + 84ba84c commit 6ee8b17
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions include/fast_io_core_impl/integers/pointer.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,16 +70,12 @@ template <::std::integral char_type, ::std::size_t n>
inline constexpr basic_os_str_known_size_without_null_terminated<char_type> os_c_str_carr(char_type const (&cstr)[n]) noexcept
{
constexpr ::std::size_t nm1{static_cast<::std::size_t>(n - 1u)};
return os_c_str(cstr, n);
return os_c_str(cstr, nm1);
}

template <::std::integral char_type>
inline constexpr basic_os_c_str_with_known_size<char_type> os_c_str_null_terminated(char_type const *ch, ::std::size_t n) noexcept
{
if (ch[n] != 0) [[unlikely]]
{
::fast_io::fast_terminate();
}
return {ch, n};
}

Expand Down

0 comments on commit 6ee8b17

Please sign in to comment.