blockchain: error out if the builtin hashes data size is wrong

This commit is contained in:
moneromooo-monero 2019-11-12 12:42:24 +00:00
parent a48ef0a65a
commit 21d4c21619
No known key found for this signature in database
GPG Key ID: 686F07454D6CEFC3
1 changed files with 6 additions and 1 deletions

View File

@ -5074,7 +5074,12 @@ void Blockchain::load_compiled_in_block_hashes(const GetCheckpointsCallback& get
return;
}
const size_t size_needed = 4 + nblocks * (sizeof(crypto::hash) * 2);
if(nblocks > 0 && nblocks > (m_db->height() + HASH_OF_HASHES_STEP - 1) / HASH_OF_HASHES_STEP && checkpoints.size() >= size_needed)
if(checkpoints.size() != size_needed)
{
MERROR("Failed to load hashes - unexpected data size");
return;
}
else if(nblocks > 0 && nblocks > (m_db->height() + HASH_OF_HASHES_STEP - 1) / HASH_OF_HASHES_STEP)
{
p += sizeof(uint32_t);
m_blocks_hash_of_hashes.reserve(nblocks);