File tree Expand file tree Collapse file tree 4 files changed +10
-11
lines changed Expand file tree Collapse file tree 4 files changed +10
-11
lines changed Original file line number Diff line number Diff line change 3030#include < stdint.h>
3131#include < unistd.h>
3232
33- #include < vector>
34-
3533#include < test/fuzz/fuzz.h>
3634
3735void initialize_deserialize ()
@@ -71,7 +69,7 @@ T Deserialize(CDataStream ds)
7169}
7270
7371template <typename T>
74- void DeserializeFromFuzzingInput (const std::vector< uint8_t >& buffer, T& obj, const Optional<int > protocol_version = nullopt )
72+ void DeserializeFromFuzzingInput (FuzzBufferType buffer, T& obj, const Optional<int > protocol_version = nullopt )
7573{
7674 CDataStream ds (buffer, SER_NETWORK, INIT_PROTO_VERSION);
7775 if (protocol_version) {
Original file line number Diff line number Diff line change @@ -59,8 +59,7 @@ static bool read_stdin(std::vector<uint8_t>& data)
5959extern " C" int LLVMFuzzerTestOneInput (const uint8_t * data, size_t size)
6060{
6161 static const auto & test_one_input = *Assert (g_test_one_input);
62- const std::vector<uint8_t > input (data, data + size);
63- test_one_input (input);
62+ test_one_input ({data, size});
6463 return 0 ;
6564}
6665
Original file line number Diff line number Diff line change 55#ifndef BITCOIN_TEST_FUZZ_FUZZ_H
66#define BITCOIN_TEST_FUZZ_FUZZ_H
77
8+ #include < span.h>
9+
810#include < cstdint>
911#include < functional>
1012#include < string_view>
11- #include < vector>
1213
13- using TypeTestOneInput = std::function<void (const std::vector<uint8_t >&)>;
14+ using FuzzBufferType = Span<const uint8_t >;
15+
16+ using TypeTestOneInput = std::function<void (FuzzBufferType)>;
1417using TypeInitialize = std::function<void ()>;
1518
1619void FuzzFrameworkRegisterTarget (std::string_view name, TypeTestOneInput target, TypeInitialize init);
@@ -21,13 +24,13 @@ inline void FuzzFrameworkEmptyFun() {}
2124 FUZZ_TARGET_INIT (name, FuzzFrameworkEmptyFun)
2225
2326#define FUZZ_TARGET_INIT (name, init_fun ) \
24- void name##_fuzz_target(const std::vector< uint8_t >&); \
27+ void name##_fuzz_target(FuzzBufferType); \
2528 struct name ##_Before_Main { \
2629 name##_Before_Main() \
2730 { \
2831 FuzzFrameworkRegisterTarget (#name, name##_fuzz_target, init_fun); \
2932 } \
3033 } const static g_##name##_before_main; \
31- void name##_fuzz_target(const std::vector< uint8_t >& buffer)
34+ void name##_fuzz_target(FuzzBufferType buffer)
3235
3336#endif // BITCOIN_TEST_FUZZ_FUZZ_H
Original file line number Diff line number Diff line change 3030#include < iostream>
3131#include < memory>
3232#include < string>
33- #include < vector>
3433
3534namespace {
3635const TestingSetup* g_setup;
@@ -46,7 +45,7 @@ void initialize_process_message()
4645 SyncWithValidationInterfaceQueue ();
4746}
4847
49- void fuzz_target (const std::vector< uint8_t >& buffer, const std::string& LIMIT_TO_MESSAGE_TYPE)
48+ void fuzz_target (FuzzBufferType buffer, const std::string& LIMIT_TO_MESSAGE_TYPE)
5049{
5150 FuzzedDataProvider fuzzed_data_provider (buffer.data (), buffer.size ());
5251
You can’t perform that action at this time.
0 commit comments