File tree Expand file tree Collapse file tree 3 files changed +55
-0
lines changed Expand file tree Collapse file tree 3 files changed +55
-0
lines changed Original file line number Diff line number Diff line change @@ -39,6 +39,7 @@ FUZZ_TARGETS = \
39
39
test/fuzz/messageheader_deserialize \
40
40
test/fuzz/netaddr_deserialize \
41
41
test/fuzz/out_point_deserialize \
42
+ test/fuzz/p2p_transport_deserializer \
42
43
test/fuzz/parse_hd_keypath \
43
44
test/fuzz/parse_iso8601 \
44
45
test/fuzz/parse_numbers \
@@ -452,6 +453,12 @@ test_fuzz_out_point_deserialize_LDADD = $(FUZZ_SUITE_LD_COMMON)
452
453
test_fuzz_out_point_deserialize_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(LIBTOOL_APP_LDFLAGS)
453
454
test_fuzz_out_point_deserialize_SOURCES = $(FUZZ_SUITE) test/fuzz/deserialize.cpp
454
455
456
+ test_fuzz_p2p_transport_deserializer_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES)
457
+ test_fuzz_p2p_transport_deserializer_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS)
458
+ test_fuzz_p2p_transport_deserializer_LDADD = $(FUZZ_SUITE_LD_COMMON)
459
+ test_fuzz_p2p_transport_deserializer_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(LIBTOOL_APP_LDFLAGS)
460
+ test_fuzz_p2p_transport_deserializer_SOURCES = $(FUZZ_SUITE) test/fuzz/p2p_transport_deserializer.cpp
461
+
455
462
test_fuzz_parse_hd_keypath_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES)
456
463
test_fuzz_parse_hd_keypath_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS)
457
464
test_fuzz_parse_hd_keypath_LDADD = $(FUZZ_SUITE_LD_COMMON)
Original file line number Diff line number Diff line change
1
+ // Copyright (c) 2019 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 < chainparams.h>
6
+ #include < net.h>
7
+ #include < protocol.h>
8
+ #include < test/fuzz/fuzz.h>
9
+
10
+ #include < cassert>
11
+ #include < cstdint>
12
+ #include < limits>
13
+ #include < vector>
14
+
15
+ void initialize ()
16
+ {
17
+ SelectParams (CBaseChainParams::REGTEST);
18
+ }
19
+
20
+ void test_one_input (const std::vector<uint8_t >& buffer)
21
+ {
22
+ V1TransportDeserializer deserializer{Params ().MessageStart (), SER_NETWORK, INIT_PROTO_VERSION};
23
+ const char * pch = (const char *)buffer.data ();
24
+ size_t n_bytes = buffer.size ();
25
+ while (n_bytes > 0 ) {
26
+ const int handled = deserializer.Read (pch, n_bytes);
27
+ if (handled < 0 ) {
28
+ break ;
29
+ }
30
+ pch += handled;
31
+ n_bytes -= handled;
32
+ if (deserializer.Complete ()) {
33
+ const int64_t m_time = std::numeric_limits<int64_t >::max ();
34
+ const CNetMessage msg = deserializer.GetMessage (Params ().MessageStart (), m_time);
35
+ assert (msg.m_command .size () <= CMessageHeader::COMMAND_SIZE);
36
+ assert (msg.m_raw_message_size <= buffer.size ());
37
+ assert (msg.m_raw_message_size == CMessageHeader::HEADER_SIZE + msg.m_message_size );
38
+ assert (msg.m_time == m_time);
39
+ if (msg.m_valid_header ) {
40
+ assert (msg.m_valid_netmagic );
41
+ }
42
+ if (!msg.m_valid_netmagic ) {
43
+ assert (!msg.m_valid_header );
44
+ }
45
+ }
46
+ }
47
+ }
Original file line number Diff line number Diff line change 30
30
"key_origin_info_deserialize" ,
31
31
"merkle_block_deserialize" ,
32
32
"out_point_deserialize" ,
33
+ "p2p_transport_deserializer" ,
33
34
"parse_hd_keypath" ,
34
35
"parse_numbers" ,
35
36
"parse_script" ,
You can’t perform that action at this time.
0 commit comments