Branch data Line data Source code
1 : : // Copyright (c) 2019-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 <test/fuzz/FuzzedDataProvider.h> 6 : : #include <test/fuzz/fuzz.h> 7 : : #include <util/spanparsing.h> 8 : : 9 [ + - ][ + - ]: 6 : FUZZ_TARGET(spanparsing) 10 : : { 11 : 0 : FuzzedDataProvider fuzzed_data_provider(buffer.data(), buffer.size()); 12 : 0 : const size_t query_size = fuzzed_data_provider.ConsumeIntegral<size_t>(); 13 : 0 : const std::string query = fuzzed_data_provider.ConsumeBytesAsString(std::min<size_t>(query_size, 1024 * 1024)); 14 [ # # ]: 0 : const std::string span_str = fuzzed_data_provider.ConsumeRemainingBytesAsString(); 15 [ # # ]: 0 : const Span<const char> const_span{span_str}; 16 : : 17 : 0 : Span<const char> mut_span = const_span; 18 [ # # ]: 0 : (void)spanparsing::Const(query, mut_span); 19 : : 20 : 0 : mut_span = const_span; 21 [ # # ]: 0 : (void)spanparsing::Func(query, mut_span); 22 : : 23 : 0 : mut_span = const_span; 24 [ # # ]: 0 : (void)spanparsing::Expr(mut_span); 25 : 2 : 26 [ # # ]: 0 : if (!query.empty()) { 27 : 0 : mut_span = const_span; 28 [ # # ]: 0 : (void)spanparsing::Split(mut_span, query.front()); 29 : 0 : } 30 : 0 : }