diff options
author | MarcoFalke <falke.marco@gmail.com> | 2021-07-25 12:31:47 +0200 |
---|---|---|
committer | MarcoFalke <falke.marco@gmail.com> | 2021-07-25 12:31:53 +0200 |
commit | 2735e111eba32bc97b25960c626dd573447cdbee (patch) | |
tree | 06af7a62f4157ffbeb3340b620c5296da0587ee7 /src/test | |
parent | 8bc4a11409aed8054d27bdaa8a2ad20d10195de5 (diff) | |
parent | faafda232e1d4f79ee64dbfee699a8018f25b0bc (diff) |
Merge bitcoin/bitcoin#22444: fuzz: Limit max ops in prevector fuzz target
faafda232e1d4f79ee64dbfee699a8018f25b0bc 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 faafda232e1d4f79ee64dbfee699a8018f25b0bc
Tree-SHA512: 1bf166c4a99a8ce88bdc030cd6a32ce1da5251b73873772e0e9c001ec2bacafebb183f7c8c88806d0ab633aada2cff8b78791f5c9c0c6f2cc8ef5f0875c4b2ef
Diffstat (limited to 'src/test')
-rw-r--r-- | src/test/fuzz/prevector.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/test/fuzz/prevector.cpp b/src/test/fuzz/prevector.cpp index 51956bbe9e..447f32ed16 100644 --- a/src/test/fuzz/prevector.cpp +++ b/src/test/fuzz/prevector.cpp @@ -206,10 +206,14 @@ public: FUZZ_TARGET(prevector) { + // Pick an arbitrary upper bound to limit the runtime and avoid timeouts on + // inputs. + int limit_max_ops{3000}; + FuzzedDataProvider prov(buffer.data(), buffer.size()); prevector_tester<8, int> test; - while (prov.remaining_bytes()) { + while (--limit_max_ops >= 0 && prov.remaining_bytes()) { switch (prov.ConsumeIntegralInRange<int>(0, 13 + 3 * (test.size() > 0))) { case 0: test.insert(prov.ConsumeIntegralInRange<size_t>(0, test.size()), prov.ConsumeIntegral<int>()); |