File tree Expand file tree Collapse file tree 2 files changed +37
-0
lines changed Expand file tree Collapse file tree 2 files changed +37
-0
lines changed Original file line number Diff line number Diff line change @@ -23,6 +23,7 @@ FUZZ_TARGETS = \
23
23
test/fuzz/netaddr_deserialize \
24
24
test/fuzz/script_flags \
25
25
test/fuzz/service_deserialize \
26
+ test/fuzz/spanparsing \
26
27
test/fuzz/transaction \
27
28
test/fuzz/txoutcompressor_deserialize \
28
29
test/fuzz/txundo_deserialize
@@ -270,6 +271,12 @@ test_fuzz_service_deserialize_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS)
270
271
test_fuzz_service_deserialize_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(LIBTOOL_APP_LDFLAGS)
271
272
test_fuzz_service_deserialize_LDADD = $(FUZZ_SUITE_LD_COMMON)
272
273
274
+ test_fuzz_spanparsing_SOURCES = $(FUZZ_SUITE) test/fuzz/spanparsing.cpp
275
+ test_fuzz_spanparsing_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES)
276
+ test_fuzz_spanparsing_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS)
277
+ test_fuzz_spanparsing_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(LIBTOOL_APP_LDFLAGS)
278
+ test_fuzz_spanparsing_LDADD = $(FUZZ_SUITE_LD_COMMON)
279
+
273
280
test_fuzz_messageheader_deserialize_SOURCES = $(FUZZ_SUITE) test/fuzz/deserialize.cpp
274
281
test_fuzz_messageheader_deserialize_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES) -DMESSAGEHEADER_DESERIALIZE=1
275
282
test_fuzz_messageheader_deserialize_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS)
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 < test/fuzz/FuzzedDataProvider.h>
6
+ #include < test/fuzz/fuzz.h>
7
+ #include < util/spanparsing.h>
8
+
9
+ void test_one_input (const std::vector<uint8_t >& buffer)
10
+ {
11
+ FuzzedDataProvider fuzzed_data_provider (buffer.data (), buffer.size ());
12
+ const size_t query_size = fuzzed_data_provider.ConsumeIntegral <size_t >();
13
+ const std::string query = fuzzed_data_provider.ConsumeBytesAsString (std::min<size_t >(query_size, 1024 * 1024 ));
14
+ const std::string span_str = fuzzed_data_provider.ConsumeRemainingBytesAsString ();
15
+ const Span<const char > const_span = MakeSpan (span_str);
16
+
17
+ Span<const char > mut_span = const_span;
18
+ (void )spanparsing::Const (query, mut_span);
19
+
20
+ mut_span = const_span;
21
+ (void )spanparsing::Func (query, mut_span);
22
+
23
+ mut_span = const_span;
24
+ (void )spanparsing::Expr (mut_span);
25
+
26
+ if (!query.empty ()) {
27
+ mut_span = const_span;
28
+ (void )spanparsing::Split (mut_span, query.front ());
29
+ }
30
+ }
You can’t perform that action at this time.
0 commit comments