Merge bitcoin/bitcoin#24441: fuzz: Limit script_format to 100kB

bbbbeaf9c8 fuzz: Limit script_format to 100kB (MarcoFalke)

Pull request description:

  The target is still one of the slowest ones, but doesn't seem incredibly important. Especially for sizes larger than the standard tx size.

  Fix that by limiting the script size.

ACKs for top commit:
  fanquake:
    ACK bbbbeaf9c8

Tree-SHA512: b6cf7248753909ef2f21d8824f187e7c05732dd3b99619c0067f862f3c2b0f9a87779d4ddbbd3a7a4bae5c794280e2f0a223bf835d6bc6ccaba01817d69479a2
This commit is contained in:
fanquake 2022-03-04 09:33:15 +00:00
commit 4fae737f4b
No known key found for this signature in database
GPG Key ID: 2EEB9F5CC09526C1

View File

@ -3,7 +3,9 @@
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include <chainparams.h>
#include <consensus/consensus.h>
#include <core_io.h>
#include <policy/policy.h>
#include <script/script.h>
#include <test/fuzz/FuzzedDataProvider.h>
#include <test/fuzz/fuzz.h>
@ -19,6 +21,9 @@ FUZZ_TARGET_INIT(script_format, initialize_script_format)
{
FuzzedDataProvider fuzzed_data_provider(buffer.data(), buffer.size());
const CScript script{ConsumeScript(fuzzed_data_provider)};
if (script.size() > MAX_STANDARD_TX_WEIGHT / WITNESS_SCALE_FACTOR) {
return;
}
(void)FormatScript(script);
(void)ScriptToAsmStr(script, /*fAttemptSighashDecode=*/fuzzed_data_provider.ConsumeBool());