Skip to content

Commit

Permalink
Merge bitcoin#10409: [tests] Add fuzz testing for BlockTransactions a…
Browse files Browse the repository at this point in the history
…nd 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
  • Loading branch information
laanwj authored and PastaPastaPasta committed Jan 2, 2020
1 parent 39e659e commit 7254b88
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/test/test_dash_fuzzy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include "undo.h"
#include "version.h"
#include "pubkey.h"
#include "blockencodings.h"

#include <stdint.h>
#include <unistd.h>
Expand All @@ -45,6 +46,8 @@ enum TEST_ID {
CBLOOMFILTER_DESERIALIZE,
CDISKBLOCKINDEX_DESERIALIZE,
CTXOUTCOMPRESSOR_DESERIALIZE,
BLOCKTRANSACTIONS_DESERIALIZE,
BLOCKTRANSACTIONSREQUEST_DESERIALIZE,
TEST_ID_END
};

Expand Down Expand Up @@ -249,6 +252,26 @@ int do_fuzz()

break;
}
case BLOCKTRANSACTIONS_DESERIALIZE:
{
try
{
BlockTransactions bt;
ds >> bt;
} catch (const std::ios_base::failure& e) {return 0;}

break;
}
case BLOCKTRANSACTIONSREQUEST_DESERIALIZE:
{
try
{
BlockTransactionsRequest btr;
ds >> btr;
} catch (const std::ios_base::failure& e) {return 0;}

break;
}
default:
return 0;
}
Expand Down

0 comments on commit 7254b88

Please sign in to comment.