Skip to content

Commit 4c79a14

Browse files
committed
fix(fuzz): remove invalid assertion in decode_tx harness
The decode_tx fuzz target asserted that DecodeHexTx() always fails, inherited from Bitcoin Core where random fuzz bytes essentially never produce valid transactions. With real Dash chain data as corpus input (e.g. AssetUnlockTx), valid transactions decode successfully, causing a false-positive crash. Remove the assertion to allow both success and failure paths to be exercised.
1 parent 01add0b commit 4c79a14

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

src/test/fuzz/decode_tx.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,5 @@ FUZZ_TARGET(decode_tx)
1616
{
1717
const std::string tx_hex = HexStr(std::string{buffer.begin(), buffer.end()});
1818
CMutableTransaction mtx;
19-
const bool result_none = DecodeHexTx(mtx, tx_hex);
20-
assert(!result_none);
19+
(void)DecodeHexTx(mtx, tx_hex);
2120
}

src/test/fuzz/fuzz.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include <fs.h>
88
#include <netaddress.h>
99
#include <netbase.h>
10+
#include <stats/client.h>
1011
#include <test/util/setup_common.h>
1112
#include <util/check.h>
1213
#include <util/sock.h>
@@ -98,6 +99,12 @@ void ResetCoverageCounters() {}
9899

99100
void initialize()
100101
{
102+
// Initialize a no-op stats client to prevent null dereferences in production
103+
// code that unconditionally calls g_stats_client->timing()/inc()/count().
104+
if (!::g_stats_client) {
105+
::g_stats_client = std::make_unique<StatsdClient>();
106+
}
107+
101108
// Terminate immediately if a fuzzing harness ever tries to create a TCP socket.
102109
CreateSock = [](const sa_family_t&) -> std::unique_ptr<Sock> { std::terminate(); };
103110

0 commit comments

Comments
 (0)