diff options
author | MarcoFalke <falke.marco@gmail.com> | 2021-08-06 12:39:11 +0200 |
---|---|---|
committer | MarcoFalke <falke.marco@gmail.com> | 2021-08-06 12:31:28 +0200 |
commit | fa7718344d2879bb3f3c00a4185c5445390c017d (patch) | |
tree | 9454aec46e7ed4fb7c8db8c515eb877a24f26385 /src | |
parent | d67330d11245b11fbdd5e2dd5343ee451186931e (diff) |
fuzz: Avoid OOM in system fuzz target
Diffstat (limited to 'src')
-rw-r--r-- | src/test/fuzz/fuzz.h | 3 | ||||
-rw-r--r-- | src/test/fuzz/system.cpp | 3 |
2 files changed, 5 insertions, 1 deletions
diff --git a/src/test/fuzz/fuzz.h b/src/test/fuzz/fuzz.h index 2bad77bdc1..ce8fd660aa 100644 --- a/src/test/fuzz/fuzz.h +++ b/src/test/fuzz/fuzz.h @@ -11,6 +11,9 @@ #include <functional> #include <string_view> +#define LIMITED_WHILE(condition, limit) \ + for (unsigned _count{limit}; (condition) && _count; --_count) + using FuzzBufferType = Span<const uint8_t>; using TypeTestOneInput = std::function<void(FuzzBufferType)>; diff --git a/src/test/fuzz/system.cpp b/src/test/fuzz/system.cpp index b25dcfcd3b..0f53939eac 100644 --- a/src/test/fuzz/system.cpp +++ b/src/test/fuzz/system.cpp @@ -31,7 +31,8 @@ FUZZ_TARGET(system) SetupHelpOptions(args_manager); } - while (fuzzed_data_provider.ConsumeBool()) { + LIMITED_WHILE(fuzzed_data_provider.ConsumeBool(), 3000) + { CallOneOf( fuzzed_data_provider, [&] { |