Skip to content

Commit c6580c0

Browse files
committed
[test] demonstrate nullptr deref on short id collision
1 parent c122318 commit c6580c0

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

src/blockencodings.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
#include <unordered_map>
1919

2020
CBlockHeaderAndShortTxIDs::CBlockHeaderAndShortTxIDs(const CBlock& block) :
21-
nonce(GetRand<uint64_t>()),
21+
nonce(0),
2222
shorttxids(block.vtx.size() - 1), prefilledtxn(1), header(block) {
2323
FillShortTxIDSelector();
2424
//TODO: Use our mempool prior to block acceptance to predictively fill more than just the coinbase
@@ -42,7 +42,7 @@ void CBlockHeaderAndShortTxIDs::FillShortTxIDSelector() const {
4242

4343
uint64_t CBlockHeaderAndShortTxIDs::GetShortID(const uint256& txhash) const {
4444
static_assert(SHORTTXIDS_LENGTH == 6, "shorttxids calculation assumes 6-byte shorttxids");
45-
return SipHashUint256(shorttxidk0, shorttxidk1, txhash) & 0xffffffffffffL;
45+
return SipHashUint256(shorttxidk0, shorttxidk1, txhash) & 0xffL;
4646
}
4747

4848

src/test/fuzz/partially_downloaded_block.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ FUZZ_TARGET(partially_downloaded_block, .init = initialize_pdb)
7979
}
8080
}
8181

82+
extra_txn.emplace_back(uint256{}, nullptr);
8283
auto init_status{pdb.InitData(cmpctblock, extra_txn)};
8384

8485
std::vector<CTransactionRef> missing;

0 commit comments

Comments
 (0)