Skip to content

Commit 42b00a3

Browse files
author
MarcoFalke
committed
Merge bitcoin/bitcoin#22649: fuzz: Avoid OOM in system fuzz target
fa77183 fuzz: Avoid OOM in system fuzz target (MarcoFalke) Pull request description: If the inputs size is unlimited, the target may consume unlimited memory, because the argsmanager stores the argument names. Limiting the size should fix this issue. Should fix https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=36906 ACKs for top commit: practicalswift: cr ACK fa77183 Tree-SHA512: 6edfcf324ee9d94e511038ee01340f02db50bcb233af3f1a1717c3602164c88528d9d987e971ec32f1a4593b868019bea0102c53c9b02bfefec3dfde959483cf
2 parents 3facf0a + fa77183 commit 42b00a3

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

src/test/fuzz/fuzz.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111
#include <functional>
1212
#include <string_view>
1313

14+
#define LIMITED_WHILE(condition, limit) \
15+
for (unsigned _count{limit}; (condition) && _count; --_count)
16+
1417
using FuzzBufferType = Span<const uint8_t>;
1518

1619
using TypeTestOneInput = std::function<void(FuzzBufferType)>;

src/test/fuzz/system.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ FUZZ_TARGET(system)
3131
SetupHelpOptions(args_manager);
3232
}
3333

34-
while (fuzzed_data_provider.ConsumeBool()) {
34+
LIMITED_WHILE(fuzzed_data_provider.ConsumeBool(), 3000)
35+
{
3536
CallOneOf(
3637
fuzzed_data_provider,
3738
[&] {

0 commit comments

Comments
 (0)