blob: 46bc38fdabac579152096261a6381ed51767f901 (
plain)
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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
|
// Copyright (c) 2009-2019 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 <addrdb.h>
#include <addrman.h>
#include <blockencodings.h>
#include <blockfilter.h>
#include <chain.h>
#include <coins.h>
#include <compressor.h>
#include <consensus/merkle.h>
#include <key.h>
#include <merkleblock.h>
#include <net.h>
#include <primitives/block.h>
#include <protocol.h>
#include <psbt.h>
#include <pubkey.h>
#include <script/keyorigin.h>
#include <streams.h>
#include <undo.h>
#include <version.h>
#include <stdexcept>
#include <stdint.h>
#include <unistd.h>
#include <vector>
#include <test/fuzz/fuzz.h>
void initialize()
{
// Fuzzers using pubkey must hold an ECCVerifyHandle.
static const auto verify_handle = MakeUnique<ECCVerifyHandle>();
}
void test_one_input(const std::vector<uint8_t>& buffer)
{
CDataStream ds(buffer, SER_NETWORK, INIT_PROTO_VERSION);
try {
int nVersion;
ds >> nVersion;
ds.SetVersion(nVersion);
} catch (const std::ios_base::failure&) {
return;
}
#if BLOCK_FILTER_DESERIALIZE
try {
BlockFilter block_filter;
ds >> block_filter;
} catch (const std::ios_base::failure&) {
}
#elif ADDR_INFO_DESERIALIZE
try {
CAddrInfo addr_info;
ds >> addr_info;
} catch (const std::ios_base::failure&) {
}
#elif BLOCK_FILE_INFO_DESERIALIZE
try {
CBlockFileInfo block_file_info;
ds >> block_file_info;
} catch (const std::ios_base::failure&) {
}
#elif BLOCK_HEADER_AND_SHORT_TXIDS_DESERIALIZE
try {
CBlockHeaderAndShortTxIDs block_header_and_short_txids;
ds >> block_header_and_short_txids;
} catch (const std::ios_base::failure&) {
}
#elif FEE_RATE_DESERIALIZE
try {
CFeeRate fee_rate;
ds >> fee_rate;
} catch (const std::ios_base::failure&) {
}
#elif MERKLE_BLOCK_DESERIALIZE
try {
CMerkleBlock merkle_block;
ds >> merkle_block;
} catch (const std::ios_base::failure&) {
}
#elif OUT_POINT_DESERIALIZE
try {
COutPoint out_point;
ds >> out_point;
} catch (const std::ios_base::failure&) {
}
#elif PARTIAL_MERKLE_TREE_DESERIALIZE
try {
CPartialMerkleTree partial_merkle_tree;
ds >> partial_merkle_tree;
} catch (const std::ios_base::failure&) {
}
#elif PUB_KEY_DESERIALIZE
try {
CPubKey pub_key;
ds >> pub_key;
} catch (const std::ios_base::failure&) {
}
#elif SCRIPT_DESERIALIZE
try {
CScript script;
ds >> script;
} catch (const std::ios_base::failure&) {
}
#elif SUB_NET_DESERIALIZE
try {
CSubNet sub_net;
ds >> sub_net;
} catch (const std::ios_base::failure&) {
}
#elif TX_IN_DESERIALIZE
try {
CTxIn tx_in;
ds >> tx_in;
} catch (const std::ios_base::failure&) {
}
#elif FLAT_FILE_POS_DESERIALIZE
try {
FlatFilePos flat_file_pos;
ds >> flat_file_pos;
} catch (const std::ios_base::failure&) {
}
#elif KEY_ORIGIN_INFO_DESERIALIZE
try {
KeyOriginInfo key_origin_info;
ds >> key_origin_info;
} catch (const std::ios_base::failure&) {
}
#elif PARTIALLY_SIGNED_TRANSACTION_DESERIALIZE
try {
PartiallySignedTransaction partially_signed_transaction;
ds >> partially_signed_transaction;
} catch (const std::ios_base::failure&) {
}
#elif PREFILLED_TRANSACTION_DESERIALIZE
try {
PrefilledTransaction prefilled_transaction;
ds >> prefilled_transaction;
} catch (const std::ios_base::failure&) {
}
#elif PSBT_INPUT_DESERIALIZE
try {
PSBTInput psbt_input;
ds >> psbt_input;
} catch (const std::ios_base::failure&) {
}
#elif PSBT_OUTPUT_DESERIALIZE
try {
PSBTOutput psbt_output;
ds >> psbt_output;
} catch (const std::ios_base::failure&) {
}
#elif BLOCK_DESERIALIZE
try {
CBlock block;
ds >> block;
} catch (const std::ios_base::failure&) {
}
#elif BLOCKLOCATOR_DESERIALIZE
try {
CBlockLocator bl;
ds >> bl;
} catch (const std::ios_base::failure&) {
}
#elif BLOCKMERKLEROOT
try {
CBlock block;
ds >> block;
bool mutated;
BlockMerkleRoot(block, &mutated);
} catch (const std::ios_base::failure&) {
}
#elif ADDRMAN_DESERIALIZE
try {
CAddrMan am;
ds >> am;
} catch (const std::ios_base::failure&) {
}
#elif BLOCKHEADER_DESERIALIZE
try {
CBlockHeader bh;
ds >> bh;
} catch (const std::ios_base::failure&) {
}
#elif BANENTRY_DESERIALIZE
try {
CBanEntry be;
ds >> be;
} catch (const std::ios_base::failure&) {
}
#elif TXUNDO_DESERIALIZE
try {
CTxUndo tu;
ds >> tu;
} catch (const std::ios_base::failure&) {
}
#elif BLOCKUNDO_DESERIALIZE
try {
CBlockUndo bu;
ds >> bu;
} catch (const std::ios_base::failure&) {
}
#elif COINS_DESERIALIZE
try {
Coin coin;
ds >> coin;
} catch (const std::ios_base::failure&) {
}
#elif NETADDR_DESERIALIZE
try {
CNetAddr na;
ds >> na;
} catch (const std::ios_base::failure&) {
}
#elif SERVICE_DESERIALIZE
try {
CService s;
ds >> s;
} catch (const std::ios_base::failure&) {
}
#elif MESSAGEHEADER_DESERIALIZE
CMessageHeader::MessageStartChars pchMessageStart = {0x00, 0x00, 0x00, 0x00};
try {
CMessageHeader mh(pchMessageStart);
ds >> mh;
(void)mh.IsValid(pchMessageStart);
} catch (const std::ios_base::failure&) {
}
#elif ADDRESS_DESERIALIZE
try {
CAddress a;
ds >> a;
} catch (const std::ios_base::failure&) {
}
#elif INV_DESERIALIZE
try {
CInv i;
ds >> i;
} catch (const std::ios_base::failure&) {
}
#elif BLOOMFILTER_DESERIALIZE
try {
CBloomFilter bf;
ds >> bf;
} catch (const std::ios_base::failure&) {
}
#elif DISKBLOCKINDEX_DESERIALIZE
try {
CDiskBlockIndex dbi;
ds >> dbi;
} catch (const std::ios_base::failure&) {
}
#elif TXOUTCOMPRESSOR_DESERIALIZE
CTxOut to;
CTxOutCompressor toc(to);
try {
ds >> toc;
} catch (const std::ios_base::failure&) {
}
#elif BLOCKTRANSACTIONS_DESERIALIZE
try {
BlockTransactions bt;
ds >> bt;
} catch (const std::ios_base::failure&) {
}
#elif BLOCKTRANSACTIONSREQUEST_DESERIALIZE
try {
BlockTransactionsRequest btr;
ds >> btr;
} catch (const std::ios_base::failure&) {
}
#else
#error Need at least one fuzz target to compile
#endif
}
|