mirror of
https://github.com/bitcoin/bitcoin.git
synced 2024-11-20 02:25:40 +01:00
tests: Increase fuzzing coverage of DecompressScript(...)
This commit is contained in:
parent
9f8d74a8c7
commit
c2c58f6f59
@ -14,7 +14,9 @@
|
||||
#include <script/signingprovider.h>
|
||||
#include <script/standard.h>
|
||||
#include <streams.h>
|
||||
#include <test/fuzz/FuzzedDataProvider.h>
|
||||
#include <test/fuzz/fuzz.h>
|
||||
#include <test/fuzz/util.h>
|
||||
#include <univalue.h>
|
||||
#include <util/memory.h>
|
||||
|
||||
@ -85,4 +87,14 @@ void test_one_input(const std::vector<uint8_t>& buffer)
|
||||
ScriptToUniv(script, o3, true);
|
||||
UniValue o4(UniValue::VOBJ);
|
||||
ScriptToUniv(script, o4, false);
|
||||
|
||||
{
|
||||
FuzzedDataProvider fuzzed_data_provider(buffer.data(), buffer.size());
|
||||
const std::vector<uint8_t> bytes = ConsumeRandomLengthByteVector(fuzzed_data_provider);
|
||||
// DecompressScript(..., ..., bytes) is not guaranteed to be defined if bytes.size() <= 23.
|
||||
if (bytes.size() >= 24) {
|
||||
CScript decompressed_script;
|
||||
DecompressScript(decompressed_script, fuzzed_data_provider.ConsumeIntegral<unsigned int>(), bytes);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user