diff options
| author | Leitwolf11 | 2026-10-23 23:28:06 +0300 |
|---|---|---|
| committer | Leitwolf11 | 2026-10-23 23:28:06 +0300 |
| commit | 15eb534ee493a3388c168709eb79a954e9cb5fcf (patch) | |
| tree | a08efeb1f5184d8326d57ef358ce9d0531864f78 /fuzzing/Progmasoft/fuzz_RunnerOptions.cpp | |
| parent | 93d4e7dbebab867e0a7f59fc25308460a7a76280 (diff) | |
| download | catch3-15eb534ee493a3388c168709eb79a954e9cb5fcf.tar.gz | |
Move the runner fuzzers under fuzzing/Progmasoft
The license check expects Progmasoft's header only on paths that contain
a Progmasoft directory, so the two runner fuzzers move next to each other
under fuzzing/Progmasoft and keep their MPL header.
Diffstat (limited to 'fuzzing/Progmasoft/fuzz_RunnerOptions.cpp')
| -rw-r--r-- | fuzzing/Progmasoft/fuzz_RunnerOptions.cpp | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/fuzzing/Progmasoft/fuzz_RunnerOptions.cpp b/fuzzing/Progmasoft/fuzz_RunnerOptions.cpp new file mode 100644 index 00000000..2a10ba91 --- /dev/null +++ b/fuzzing/Progmasoft/fuzz_RunnerOptions.cpp @@ -0,0 +1,50 @@ +// Copyright (c) 2026 Progmasoft. +// SPDX-License-Identifier: MPL-2.0 WITH AdditionRef-Progmasoft-Exception-1.1 + +// The command line of a test binary: arguments separated by NUL bytes. The +// parser must answer with options or an error, never crash, and the worker +// arguments it derives must parse again. + +#include <Progmasoft/Runner/Options.hpp> + +#include <cstdint> +#include <cstdlib> +#include <string> +#include <vector> + +extern "C" int +LLVMFuzzerTestOneInput(const std::uint8_t *data, std::size_t size) +{ + std::vector<std::string> arguments(1); + for (std::size_t index = 0; index < size; ++index) + { + if (data[index] == 0) + { + arguments.emplace_back(); + } + else + { + arguments.back().push_back(static_cast<char>(data[index])); + } + } + // Reading a file named by --input-file is not what is fuzzed here. + for (const auto &argument : arguments) + { + if (argument.find("input-file") != std::string::npos || + (argument.size() >= 2 && argument[0] == '-' && argument[1] == 'f')) + { + return 0; + } + } + auto options = Progmasoft::Catch3::Runner::ParseOptions(arguments); + if (options) + { + const auto worker = Progmasoft::Catch3::Runner::ParseOptions( + Progmasoft::Catch3::Runner::WorkerArguments(*options)); + if (!worker) + { + std::abort(); + } + } + return 0; +} |