Skip to content

Commit 2735e11

Browse files
author
MarcoFalke
committed
Merge bitcoin/bitcoin#22444: fuzz: Limit max ops in prevector fuzz target
faafda2 fuzz: Speed up prevector fuzz target (MarcoFalke) Pull request description: Without a size limit on the input data, the runtime is unbounded. Fix this by picking an upper bound on the maximum number of fuzz operations. Should fix https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=35981 ACKs for top commit: practicalswift: cr ACK faafda2 Tree-SHA512: 1bf166c4a99a8ce88bdc030cd6a32ce1da5251b73873772e0e9c001ec2bacafebb183f7c8c88806d0ab633aada2cff8b78791f5c9c0c6f2cc8ef5f0875c4b2ef
2 parents 8bc4a11 + faafda2 commit 2735e11

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/test/fuzz/prevector.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,10 +206,14 @@ class prevector_tester
206206

207207
FUZZ_TARGET(prevector)
208208
{
209+
// Pick an arbitrary upper bound to limit the runtime and avoid timeouts on
210+
// inputs.
211+
int limit_max_ops{3000};
212+
209213
FuzzedDataProvider prov(buffer.data(), buffer.size());
210214
prevector_tester<8, int> test;
211215

212-
while (prov.remaining_bytes()) {
216+
while (--limit_max_ops >= 0 && prov.remaining_bytes()) {
213217
switch (prov.ConsumeIntegralInRange<int>(0, 13 + 3 * (test.size() > 0))) {
214218
case 0:
215219
test.insert(prov.ConsumeIntegralInRange<size_t>(0, test.size()), prov.ConsumeIntegral<int>());

0 commit comments

Comments
 (0)