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 18:57:52 +0300
committerGitHub2026-11-17 18:57:52 +0300
commit7ff85d401d6f7f2d37fc0566f346a521a9bb7cee (patch)
tree334a71b7a7d5b209f778cc51696ef307be3c06e2 /src/Progmasoft/Runner/Process.cpp
parenteea3be11a9e1a047442d71626557e57c3061da1a (diff)
parent98aa45f74647ab0e18d0a26615fb848f5f798745 (diff)
downloadcatch3-7ff85d401d6f7f2d37fc0566f346a521a9bb7cee.tar.gz
Merge pull request #47 from Progmasoft/security/bounded-stringsHEADdevel
Bound three string and XML reads that analysis flagged
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 a96b54e5..52c285e0 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;
}