Read-only mirrors. Development, issues and pull requests are on GitHub.

summaryrefslogtreecommitdiffhomepage
path: root/src/Progmasoft/Runner/Process.cpp
diff options
context:
space:
mode:
authorLeitwolf2026-11-17 21:28:03 +0300
committerGitHub2026-11-17 21:28:03 +0300
commit2de8e46a15b2967438125f69dc6cfbadca14573d (patch)
treeff49cb6e7f90b671577993202249f207cfc99b6d /src/Progmasoft/Runner/Process.cpp
parent7ff85d401d6f7f2d37fc0566f346a521a9bb7cee (diff)
parent7c3b73b14a3f0714c8eca3ad1a69bc1963ae773d (diff)
downloadcatch3-2de8e46a15b2967438125f69dc6cfbadca14573d.tar.gz
Merge pull request #56 from Progmasoft/fix/pipe-read-limit
Ask read() for at most SSIZE_MAX bytes in PipeReader::Read
Diffstat (limited to 'src/Progmasoft/Runner/Process.cpp')
-rw-r--r--src/Progmasoft/Runner/Process.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/Progmasoft/Runner/Process.cpp b/src/Progmasoft/Runner/Process.cpp
index 52c285e0..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);