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 [ - + ]: 398 : FUZZ_TARGET(spanparsing) 10 : : { 11 : 52 : FuzzedDataProvider fuzzed_data_provider(buffer.data(), buffer.size()); 12 : 52 : const size_t query_size = fuzzed_data_provider.ConsumeIntegral<size_t>(); 13 : 52 : const std::string query = fuzzed_data_provider.ConsumeBytesAsString(std::min<size_t>(query_size, 1024 * 1024)); 14 [ + - ]: 52 : const std::string span_str = fuzzed_data_provider.ConsumeRemainingBytesAsString(); 15 [ + - ]: 52 : const Span<const char> const_span{span_str}; 16 : : 17 : 52 : Span<const char> mut_span = const_span; 18 [ + - ]: 52 : (void)spanparsing::Const(query, mut_span); 19 : : 20 : 52 : mut_span = const_span; 21 [ + - ]: 52 : (void)spanparsing::Func(query, mut_span); 22 : : 23 : 52 : mut_span = const_span; 24 [ + - ]: 52 : (void)spanparsing::Expr(mut_span); 25 [ + - ]: 173 : 26 [ + + ]: 52 : if (!query.empty()) { 27 : 25 : mut_span = const_span; 28 [ + - ]: 25 : (void)spanparsing::Split(mut_span, query.front()); 29 : 25 : } 30 : 52 : }