diff options
| author | Leitwolf | 2026-11-17 21:28:08 +0300 |
|---|---|---|
| committer | GitHub | 2026-11-17 21:28:08 +0300 |
| commit | 73c89991c23efc41a0036b27556d386498ef22c6 (patch) | |
| tree | 0d7949c63819aad2ad8cf32d79db0aca20dac192 /src/Progmasoft/Runner/Process.cpp | |
| parent | 7d295d8be67b58267c6a82c9e481118e4c663e8c (diff) | |
| parent | 2de8e46a15b2967438125f69dc6cfbadca14573d (diff) | |
| download | catch3-73c89991c23efc41a0036b27556d386498ef22c6.tar.gz | |
Merge branch 'devel' into site/catch3-uksite/catch3-uk
Diffstat (limited to 'src/Progmasoft/Runner/Process.cpp')
| -rw-r--r-- | src/Progmasoft/Runner/Process.cpp | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/src/Progmasoft/Runner/Process.cpp b/src/Progmasoft/Runner/Process.cpp index a96b54e5..b81c121a 100644 --- a/src/Progmasoft/Runner/Process.cpp +++ b/src/Progmasoft/Runner/Process.cpp @@ -6,6 +6,7 @@ #include <cstdlib> #include <cstring> #include <iterator> +#include <limits> #include <mutex> #include <string_view> #include <thread> @@ -494,9 +495,14 @@ namespace Progmasoft::Catch3::Runner } return static_cast<std::int64_t>(read); #else + // read() leaves a request above SSIZE_MAX to the implementation, so + // one call asks for at most that much and never more than the buffer. + const auto request = std::min<std::size_t>( + size, + static_cast<std::size_t>(std::numeric_limits<ssize_t>::max())); while (true) { - const auto count = read(Descriptor(handle_), buffer, size); + const auto count = read(Descriptor(handle_), buffer, request); if (count >= 0) { return static_cast<std::int64_t>(count); @@ -1286,7 +1292,12 @@ namespace Progmasoft::Catch3::Runner std::string buffer(size, '\0'); if (_NSGetExecutablePath(buffer.data(), &size) == 0) { - buffer.resize(std::strlen(buffer.c_str())); + // The path ends at its first NUL, never past the buffer. + const auto end = buffer.find('\0'); + if (end != std::string::npos) + { + buffer.resize(end); + } auto canonical = std::filesystem::weakly_canonical(buffer, error); return error ? std::filesystem::path{ buffer } : canonical; } |