diff options
| author | Leitwolf11 | 2026-11-15 22:29:48 +0300 |
|---|---|---|
| committer | Leitwolf11 | 2026-11-15 22:29:48 +0300 |
| commit | 79f624d693b4fc3167c239c3eca47c858799333f (patch) | |
| tree | d42816753aa7f421e92dceba4e4e2b264b1a4773 /tests | |
| parent | 6750f61c28be2861280078328e164e88bc1dfe44 (diff) | |
| download | catch3-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 'tests')
| -rw-r--r-- | tests/SelfTest/UsageTests/Generators.tests.cpp | 4 | ||||
| -rw-r--r-- | tests/TestScripts/testBazelReporter.py | 9 |
2 files changed, 10 insertions, 3 deletions
diff --git a/tests/SelfTest/UsageTests/Generators.tests.cpp b/tests/SelfTest/UsageTests/Generators.tests.cpp index 655c4608..77ffde8d 100644 --- a/tests/SelfTest/UsageTests/Generators.tests.cpp +++ b/tests/SelfTest/UsageTests/Generators.tests.cpp @@ -12,7 +12,7 @@ #include <Progmasoft/Catch3/Generators/Random.hpp> #include <Progmasoft/Catch3/Generators/Range.hpp> -#include <cstring> +#include <string_view> // Generators and sections can be nested freely @@ -62,7 +62,7 @@ TEST_CASE("tables", "[generators]") { tuple_type{"etc...", 6} })); - REQUIRE(strlen(std::get<0>(data)) == static_cast<size_t>(std::get<1>(data))); + REQUIRE(std::string_view(std::get<0>(data)).size() == static_cast<size_t>(std::get<1>(data))); } diff --git a/tests/TestScripts/testBazelReporter.py b/tests/TestScripts/testBazelReporter.py index 62600a39..f91e7b0f 100644 --- a/tests/TestScripts/testBazelReporter.py +++ b/tests/TestScripts/testBazelReporter.py @@ -56,7 +56,14 @@ if ret.returncode != 42: exit(1) try: - tree = ET.parse(xml_out_path) + with open(xml_out_path, 'r', encoding='utf-8') as report: + text = report.read() + # A JUnit report has no document type, so it declares no entities: one + # that does is rejected before parsing, and no entity is ever expanded. + if '<!DOCTYPE' in text or '<!ENTITY' in text: + print("The report declares a document type: '{}'".format(xml_out_path)) + exit(2) + tree = ET.ElementTree(ET.fromstring(text)) except ET.ParseError as ex: print("Invalid XML: '{}'".format(ex)) raise |