Skip to content

Commit b5545d8

Browse files
committed
Merge #10409: [tests] Add fuzz testing for BlockTransactions and BlockTransactionsRequest
fd3a2f3 [tests] Add fuzz testing for BlockTransactions and BlockTransactionsRequest (practicalswift) Pull request description: The `BlockTransactions` deserialization code is reachable with tainted data via `ProcessMessage(…, "BLOCKTXN", vRecv [tainted], …)`. The same thing applies to `BlockTransactionsRequest` which is reachable via `"GETBLOCKTXN"`. Tree-SHA512: 64560ea344bc6145b940472f99866b808725745b060dedfb315be400bd94e55399f50b982149645bd7af7ed9935fd28751d7daf0d3f94a8e2ed3bc52e3325ffb
2 parents d93fa26 + fd3a2f3 commit b5545d8

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

src/test/test_bitcoin_fuzzy.cpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include "undo.h"
2020
#include "version.h"
2121
#include "pubkey.h"
22+
#include "blockencodings.h"
2223

2324
#include <stdint.h>
2425
#include <unistd.h>
@@ -45,6 +46,8 @@ enum TEST_ID {
4546
CBLOOMFILTER_DESERIALIZE,
4647
CDISKBLOCKINDEX_DESERIALIZE,
4748
CTXOUTCOMPRESSOR_DESERIALIZE,
49+
BLOCKTRANSACTIONS_DESERIALIZE,
50+
BLOCKTRANSACTIONSREQUEST_DESERIALIZE,
4851
TEST_ID_END
4952
};
5053

@@ -245,6 +248,26 @@ int test_one_input(std::vector<uint8_t> buffer) {
245248

246249
break;
247250
}
251+
case BLOCKTRANSACTIONS_DESERIALIZE:
252+
{
253+
try
254+
{
255+
BlockTransactions bt;
256+
ds >> bt;
257+
} catch (const std::ios_base::failure& e) {return 0;}
258+
259+
break;
260+
}
261+
case BLOCKTRANSACTIONSREQUEST_DESERIALIZE:
262+
{
263+
try
264+
{
265+
BlockTransactionsRequest btr;
266+
ds >> btr;
267+
} catch (const std::ios_base::failure& e) {return 0;}
268+
269+
break;
270+
}
248271
default:
249272
return 0;
250273
}

0 commit comments

Comments
 (0)