File tree 4 files changed +10
-11
lines changed
4 files changed +10
-11
lines changed Original file line number Diff line number Diff line change 30
30
#include < stdint.h>
31
31
#include < unistd.h>
32
32
33
- #include < vector>
34
-
35
33
#include < test/fuzz/fuzz.h>
36
34
37
35
void initialize_deserialize ()
@@ -71,7 +69,7 @@ T Deserialize(CDataStream ds)
71
69
}
72
70
73
71
template <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)
75
73
{
76
74
CDataStream ds (buffer, SER_NETWORK, INIT_PROTO_VERSION);
77
75
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)
59
59
extern " C" int LLVMFuzzerTestOneInput (const uint8_t * data, size_t size)
60
60
{
61
61
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});
64
63
return 0 ;
65
64
}
66
65
Original file line number Diff line number Diff line change 5
5
#ifndef BITCOIN_TEST_FUZZ_FUZZ_H
6
6
#define BITCOIN_TEST_FUZZ_FUZZ_H
7
7
8
+ #include < span.h>
9
+
8
10
#include < cstdint>
9
11
#include < functional>
10
12
#include < string_view>
11
- #include < vector>
12
13
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)>;
14
17
using TypeInitialize = std::function<void ()>;
15
18
16
19
void FuzzFrameworkRegisterTarget (std::string_view name, TypeTestOneInput target, TypeInitialize init);
@@ -21,13 +24,13 @@ inline void FuzzFrameworkEmptyFun() {}
21
24
FUZZ_TARGET_INIT (name, FuzzFrameworkEmptyFun)
22
25
23
26
#define FUZZ_TARGET_INIT (name, init_fun ) \
24
- void name##_fuzz_target(const std::vector< uint8_t >&); \
27
+ void name##_fuzz_target(FuzzBufferType); \
25
28
struct name ##_Before_Main { \
26
29
name##_Before_Main() \
27
30
{ \
28
31
FuzzFrameworkRegisterTarget (#name, name##_fuzz_target, init_fun); \
29
32
} \
30
33
} const static g_##name##_before_main; \
31
- void name##_fuzz_target(const std::vector< uint8_t >& buffer)
34
+ void name##_fuzz_target(FuzzBufferType buffer)
32
35
33
36
#endif // BITCOIN_TEST_FUZZ_FUZZ_H
Original file line number Diff line number Diff line change 30
30
#include < iostream>
31
31
#include < memory>
32
32
#include < string>
33
- #include < vector>
34
33
35
34
namespace {
36
35
const TestingSetup* g_setup;
@@ -46,7 +45,7 @@ void initialize_process_message()
46
45
SyncWithValidationInterfaceQueue ();
47
46
}
48
47
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)
50
49
{
51
50
FuzzedDataProvider fuzzed_data_provider (buffer.data (), buffer.size ());
52
51
You can’t perform that action at this time.
0 commit comments