diff options
author | practicalswift <practicalswift@users.noreply.github.com> | 2020-03-10 11:58:30 +0000 |
---|---|---|
committer | practicalswift <practicalswift@users.noreply.github.com> | 2020-03-11 12:51:26 +0000 |
commit | c2c58f6f59d38e3d60fe0a8fa45b2a45deee84cc (patch) | |
tree | d2cf1ec4a54585b93ac431c63d12170b307f7b21 /src/test | |
parent | 9f8d74a8c78457ed49c7ff81bae909c8e003670b (diff) |
tests: Increase fuzzing coverage of DecompressScript(...)
Diffstat (limited to 'src/test')
-rw-r--r-- | src/test/fuzz/script.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/test/fuzz/script.cpp b/src/test/fuzz/script.cpp index ca8b136c2d..4961bba477 100644 --- a/src/test/fuzz/script.cpp +++ b/src/test/fuzz/script.cpp @@ -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); + } + } } |