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 @@ -37,6 +37,7 @@ FUZZ_TARGETS = \
3737 test/fuzz/messageheader_deserialize \
3838 test/fuzz/netaddr_deserialize \
3939 test/fuzz/out_point_deserialize \
40+ test/fuzz/p2p_transport_deserializer \
4041 test/fuzz/parse_hd_keypath \
4142 test/fuzz/parse_iso8601 \
4243 test/fuzz/parse_numbers \
@@ -433,6 +434,12 @@ test_fuzz_out_point_deserialize_LDADD = $(FUZZ_SUITE_LD_COMMON)
433434test_fuzz_out_point_deserialize_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(LIBTOOL_APP_LDFLAGS)
434435test_fuzz_out_point_deserialize_SOURCES = $(FUZZ_SUITE) test/fuzz/deserialize.cpp
435436
437+ test_fuzz_p2p_transport_deserializer_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES)
438+ test_fuzz_p2p_transport_deserializer_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS)
439+ test_fuzz_p2p_transport_deserializer_LDADD = $(FUZZ_SUITE_LD_COMMON)
440+ test_fuzz_p2p_transport_deserializer_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(LIBTOOL_APP_LDFLAGS)
441+ test_fuzz_p2p_transport_deserializer_SOURCES = $(FUZZ_SUITE) test/fuzz/p2p_transport_deserializer.cpp
442+
436443test_fuzz_parse_hd_keypath_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES)
437444test_fuzz_parse_hd_keypath_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS)
438445test_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 2828 "key_origin_info_deserialize" ,
2929 "merkle_block_deserialize" ,
3030 "out_point_deserialize" ,
31+ "p2p_transport_deserializer" ,
3132 "parse_hd_keypath" ,
3233 "parse_numbers" ,
3334 "parse_script" ,
You can’t perform that action at this time.
0 commit comments