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

summaryrefslogtreecommitdiffhomepage
path: root/src/Progmasoft/Runner/Process.cpp
diff options
context:
space:
mode:
authorLeitwolf112026-11-15 22:29:48 +0300
committerLeitwolf112026-11-15 22:29:48 +0300
commit79f624d693b4fc3167c239c3eca47c858799333f (patch)
treed42816753aa7f421e92dceba4e4e2b264b1a4773 /src/Progmasoft/Runner/Process.cpp
parent6750f61c28be2861280078328e164e88bc1dfe44 (diff)
downloadcatch3-79f624d693b4fc3167c239c3eca47c858799333f.tar.gz
Bound three string and XML reads that analysis flagged
- On macOS, the path from _NSGetExecutablePath is cut at its first NUL found inside the buffer, in place of strlen, which reads until a NUL wherever it is. - The table test measures its C strings with std::string_view. - The Bazel reporter test reads the JUnit report and rejects a document type before parsing it, so no entity, external or internal, is ever expanded. Claude-Session: https://claude.ai/code/session_01Ji7xZMYjc4zankoc7hGBE1
Diffstat (limited to 'src/Progmasoft/Runner/Process.cpp')
-rw-r--r--src/Progmasoft/Runner/Process.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/Progmasoft/Runner/Process.cpp b/src/Progmasoft/Runner/Process.cpp
index e3b0997b..b858d1e6 100644
--- a/src/Progmasoft/Runner/Process.cpp
+++ b/src/Progmasoft/Runner/Process.cpp
@@ -1286,7 +1286,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;
}