@@ -57,18 +57,20 @@ auto& PickValue(FuzzedDataProvider& fuzzed_data_provider, Collection& col)
57
57
return *it;
58
58
}
59
59
60
- [[nodiscard]] inline std::vector<uint8_t > ConsumeRandomLengthByteVector (FuzzedDataProvider& fuzzed_data_provider, const size_t max_length = 4096 ) noexcept
60
+ [[nodiscard]] inline std::vector<uint8_t > ConsumeRandomLengthByteVector (FuzzedDataProvider& fuzzed_data_provider, const std::optional< size_t >& max_length = std::nullopt ) noexcept
61
61
{
62
- const std::string s = fuzzed_data_provider.ConsumeRandomLengthString (max_length);
62
+ const std::string s = max_length ?
63
+ fuzzed_data_provider.ConsumeRandomLengthString (*max_length) :
64
+ fuzzed_data_provider.ConsumeRandomLengthString ();
63
65
return {s.begin (), s.end ()};
64
66
}
65
67
66
- [[nodiscard]] inline std::vector<bool > ConsumeRandomLengthBitVector (FuzzedDataProvider& fuzzed_data_provider, const size_t max_length = 4096 ) noexcept
68
+ [[nodiscard]] inline std::vector<bool > ConsumeRandomLengthBitVector (FuzzedDataProvider& fuzzed_data_provider, const std::optional< size_t >& max_length = std::nullopt ) noexcept
67
69
{
68
70
return BytesToBits (ConsumeRandomLengthByteVector (fuzzed_data_provider, max_length));
69
71
}
70
72
71
- [[nodiscard]] inline CDataStream ConsumeDataStream (FuzzedDataProvider& fuzzed_data_provider, const size_t max_length = 4096 ) noexcept
73
+ [[nodiscard]] inline CDataStream ConsumeDataStream (FuzzedDataProvider& fuzzed_data_provider, const std::optional< size_t >& max_length = std::nullopt ) noexcept
72
74
{
73
75
return CDataStream{ConsumeRandomLengthByteVector (fuzzed_data_provider, max_length), SER_NETWORK, INIT_PROTO_VERSION};
74
76
}
@@ -95,7 +97,7 @@ template <typename T>
95
97
}
96
98
97
99
template <typename T>
98
- [[nodiscard]] inline std::optional<T> ConsumeDeserializable (FuzzedDataProvider& fuzzed_data_provider, const size_t max_length = 4096 ) noexcept
100
+ [[nodiscard]] inline std::optional<T> ConsumeDeserializable (FuzzedDataProvider& fuzzed_data_provider, const std::optional< size_t >& max_length = std::nullopt ) noexcept
99
101
{
100
102
const std::vector<uint8_t > buffer = ConsumeRandomLengthByteVector (fuzzed_data_provider, max_length);
101
103
CDataStream ds{buffer, SER_NETWORK, INIT_PROTO_VERSION};
@@ -132,7 +134,7 @@ template <typename WeakEnumType, size_t size>
132
134
133
135
[[nodiscard]] CScriptWitness ConsumeScriptWitness (FuzzedDataProvider& fuzzed_data_provider, const size_t max_stack_elem_size = 32 ) noexcept ;
134
136
135
- [[nodiscard]] CScript ConsumeScript (FuzzedDataProvider& fuzzed_data_provider, const size_t max_length = 4096 , const bool maybe_p2wsh = false ) noexcept ;
137
+ [[nodiscard]] CScript ConsumeScript (FuzzedDataProvider& fuzzed_data_provider, const std::optional< size_t >& max_length = std::nullopt , const bool maybe_p2wsh = false ) noexcept ;
136
138
137
139
[[nodiscard]] uint32_t ConsumeSequence (FuzzedDataProvider& fuzzed_data_provider) noexcept ;
138
140
0 commit comments