File tree Expand file tree Collapse file tree 2 files changed +39
-0
lines changed Expand file tree Collapse file tree 2 files changed +39
-0
lines changed Original file line number Diff line number Diff line change @@ -83,6 +83,7 @@ FUZZ_TARGETS = \
83
83
test/fuzz/process_message_tx \
84
84
test/fuzz/process_message_verack \
85
85
test/fuzz/process_message_version \
86
+ test/fuzz/protocol \
86
87
test/fuzz/psbt \
87
88
test/fuzz/psbt_input_deserialize \
88
89
test/fuzz/psbt_output_deserialize \
@@ -766,6 +767,12 @@ test_fuzz_process_message_version_LDADD = $(FUZZ_SUITE_LD_COMMON)
766
767
test_fuzz_process_message_version_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(LIBTOOL_APP_LDFLAGS)
767
768
test_fuzz_process_message_version_SOURCES = $(FUZZ_SUITE) test/fuzz/process_message.cpp
768
769
770
+ test_fuzz_protocol_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES)
771
+ test_fuzz_protocol_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS)
772
+ test_fuzz_protocol_LDADD = $(FUZZ_SUITE_LD_COMMON)
773
+ test_fuzz_protocol_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(LIBTOOL_APP_LDFLAGS)
774
+ test_fuzz_protocol_SOURCES = $(FUZZ_SUITE) test/fuzz/protocol.cpp
775
+
769
776
test_fuzz_psbt_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES)
770
777
test_fuzz_psbt_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS)
771
778
test_fuzz_psbt_LDADD = $(FUZZ_SUITE_LD_COMMON)
Original file line number Diff line number Diff line change
1
+ // Copyright (c) 2020 The Bitcoin Core developers
2
+ // Distributed under the MIT software license, see the accompanying
3
+ // file COPYING or http://www.opensource.org/licenses/mit-license.php.
4
+
5
+ #include < optional.h>
6
+ #include < protocol.h>
7
+ #include < test/fuzz/FuzzedDataProvider.h>
8
+ #include < test/fuzz/fuzz.h>
9
+ #include < test/fuzz/util.h>
10
+
11
+ #include < cstdint>
12
+ #include < stdexcept>
13
+ #include < vector>
14
+
15
+ void test_one_input (const std::vector<uint8_t >& buffer)
16
+ {
17
+ FuzzedDataProvider fuzzed_data_provider (buffer.data (), buffer.size ());
18
+ const Optional<CInv> inv = ConsumeDeserializable<CInv>(fuzzed_data_provider);
19
+ if (!inv) {
20
+ return ;
21
+ }
22
+ try {
23
+ (void )inv->GetCommand ();
24
+ } catch (const std::out_of_range&) {
25
+ }
26
+ (void )inv->ToString ();
27
+ const Optional<CInv> another_inv = ConsumeDeserializable<CInv>(fuzzed_data_provider);
28
+ if (!another_inv) {
29
+ return ;
30
+ }
31
+ (void )(*inv < *another_inv);
32
+ }
You can’t perform that action at this time.
0 commit comments