forked from bitcoin/bitcoin
-
Notifications
You must be signed in to change notification settings - Fork 1
/
parse_univalue.cpp
103 lines (99 loc) · 2.71 KB
/
parse_univalue.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
// Copyright (c) 2009-2022 The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include <chainparams.h>
#include <core_io.h>
#include <rpc/client.h>
#include <rpc/util.h>
#include <test/fuzz/fuzz.h>
#include <limits>
#include <string>
void initialize_parse_univalue()
{
SelectParams(CBaseChainParams::REGTEST);
}
FUZZ_TARGET_INIT(parse_univalue, initialize_parse_univalue)
{
const std::string random_string(buffer.begin(), buffer.end());
bool valid = true;
const UniValue univalue = [&] {
try {
return ParseNonRFCJSONValue(random_string);
} catch (const std::runtime_error&) {
valid = false;
return UniValue{};
}
}();
if (!valid) {
return;
}
try {
(void)ParseHashO(univalue, "A");
} catch (const UniValue&) {
} catch (const std::runtime_error&) {
}
try {
(void)ParseHashO(univalue, random_string);
} catch (const UniValue&) {
} catch (const std::runtime_error&) {
}
try {
(void)ParseHashV(univalue, "A");
} catch (const UniValue&) {
} catch (const std::runtime_error&) {
}
try {
(void)ParseHashV(univalue, random_string);
} catch (const UniValue&) {
} catch (const std::runtime_error&) {
}
try {
(void)ParseHexO(univalue, "A");
} catch (const UniValue&) {
}
try {
(void)ParseHexO(univalue, random_string);
} catch (const UniValue&) {
}
try {
(void)ParseHexUV(univalue, "A");
(void)ParseHexUV(univalue, random_string);
} catch (const UniValue&) {
} catch (const std::runtime_error&) {
}
try {
(void)ParseHexV(univalue, "A");
} catch (const UniValue&) {
} catch (const std::runtime_error&) {
}
try {
(void)ParseHexV(univalue, random_string);
} catch (const UniValue&) {
} catch (const std::runtime_error&) {
}
try {
(void)ParseSighashString(univalue);
} catch (const std::runtime_error&) {
}
try {
(void)AmountFromValue(univalue);
} catch (const UniValue&) {
} catch (const std::runtime_error&) {
}
try {
FlatSigningProvider provider;
(void)EvalDescriptorStringOrObject(univalue, provider);
} catch (const UniValue&) {
} catch (const std::runtime_error&) {
}
try {
(void)ParseConfirmTarget(univalue, std::numeric_limits<unsigned int>::max());
} catch (const UniValue&) {
} catch (const std::runtime_error&) {
}
try {
(void)ParseDescriptorRange(univalue);
} catch (const UniValue&) {
} catch (const std::runtime_error&) {
}
}