Bitcoin Core
32.1.0
P2P Digital Currency
Toggle main menu visibility
Loading...
Searching...
No Matches
src
test
fuzz
script_parsing.cpp
Go to the documentation of this file.
1
// Copyright (c) 2019-present 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 <
script/parsing.h
>
6
#include <
test/fuzz/FuzzedDataProvider.h
>
7
#include <
test/fuzz/fuzz.h
>
8
#include <
util/byte_units.h
>
9
#include <
util/string.h
>
10
11
using
util::Split
;
12
13
FUZZ_TARGET
(script_parsing)
14
{
15
FuzzedDataProvider
fuzzed_data_provider(buffer.data(), buffer.size());
16
const
size_t
query_size = fuzzed_data_provider.
ConsumeIntegral
<
size_t
>();
17
const
std::string query = fuzzed_data_provider.
ConsumeBytesAsString
(std::min<size_t>(query_size, 1_MiB));
18
const
std::string span_str = fuzzed_data_provider.
ConsumeRemainingBytesAsString
();
19
const
std::span<const char> const_span{span_str};
20
21
std::span<const char> mut_span = const_span;
22
(void)
script::Const
(query, mut_span);
23
24
mut_span = const_span;
25
(void)
script::Func
(query, mut_span);
26
27
mut_span = const_span;
28
(void)
script::Expr
(mut_span);
29
30
if
(!query.empty()) {
31
mut_span = const_span;
32
(void)Split(mut_span, query.front());
33
}
34
}
FuzzedDataProvider.h
byte_units.h
FuzzedDataProvider
Definition
FuzzedDataProvider.h:32
FuzzedDataProvider::ConsumeBytesAsString
std::string ConsumeBytesAsString(size_t num_bytes)
Definition
FuzzedDataProvider.h:137
FuzzedDataProvider::ConsumeRemainingBytesAsString
std::string ConsumeRemainingBytesAsString()
Definition
FuzzedDataProvider.h:188
FuzzedDataProvider::ConsumeIntegral
T ConsumeIntegral()
Definition
FuzzedDataProvider.h:195
fuzz.h
FUZZ_TARGET
#define FUZZ_TARGET(...)
Definition
fuzz.h:35
script::Expr
std::span< const char > Expr(std::span< const char > &sp)
Extract the expression that sp begins with.
Definition
parsing.cpp:31
script::Func
bool Func(const std::string &str, std::span< const char > &sp)
Parse a function call.
Definition
parsing.cpp:22
script::Const
bool Const(const std::string &str, std::span< const char > &sp, bool skip)
Parse a constant.
Definition
parsing.cpp:13
util::Split
std::vector< T > Split(std::span< const char > sp LIFETIMEBOUND, std::string_view separators, bool include_sep=false)
Split a string on any char found in separators, returning a vector.
Definition
string.h:120
parsing.h
string.h
Generated on
for Bitcoin Core by
1.18.0