Skip to content

Commit fa9ebed

Browse files
author
MarcoFalke
committed
Reject invalid coin height and output index when loading assumeutxo
1 parent 46424e9 commit fa9ebed

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

src/validation.cpp

+8
Original file line numberDiff line numberDiff line change
@@ -4989,6 +4989,14 @@ bool ChainstateManager::PopulateAndValidateSnapshot(
49894989
coins_count - coins_left);
49904990
return false;
49914991
}
4992+
if (coin.nHeight > base_height ||
4993+
outpoint.n >= std::numeric_limits<decltype(outpoint.n)>::max() // Avoid integer wrap-around in coinstats.cpp:ApplyHash
4994+
) {
4995+
LogPrintf("[snapshot] bad snapshot data after deserializing %d coins\n",
4996+
coins_count - coins_left);
4997+
return false;
4998+
}
4999+
49925000
coins_cache.EmplaceCoinInternalDANGER(std::move(outpoint), std::move(coin));
49935001

49945002
--coins_left;

test/sanitizer_suppressions/ubsan

-3
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,6 @@ unsigned-integer-overflow:crypto/
3434
unsigned-integer-overflow:FuzzedDataProvider.h
3535
unsigned-integer-overflow:hash.cpp
3636
unsigned-integer-overflow:leveldb/
37-
# temporary coinstats suppressions (will be removed and fixed in https://github.com/bitcoin/bitcoin/pull/22146)
38-
unsigned-integer-overflow:node/coinstats.cpp
39-
signed-integer-overflow:node/coinstats.cpp
4037
unsigned-integer-overflow:policy/fees.cpp
4138
unsigned-integer-overflow:prevector.h
4239
unsigned-integer-overflow:pubkey.h

0 commit comments

Comments
 (0)