mirror of
https://codeberg.org/anoncontributorxmr/monero.git
synced 2024-11-27 05:13:25 +01:00
Fixed segfault with checkpoints loading
Bounds checking on blockchain_storage' m_blocks.size() when validating against checkpoints. Also moved initial json & DNS checkpoints load to after blockchain init.
This commit is contained in:
parent
b261d9207b
commit
7568f89c55
@ -1793,6 +1793,12 @@ bool blockchain_storage::update_checkpoints(const std::string& file_path)
|
||||
|
||||
for (const auto& pt : points)
|
||||
{
|
||||
// if the checkpoint is for a block we don't have yet, move on
|
||||
if (pt.first >= m_blocks.size())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!m_checkpoints.check_block(pt.first, get_block_hash(m_blocks[pt.first].bl)))
|
||||
{
|
||||
// if we're enforcing dns checkpoints, roll back to a couple of blocks before the checkpoint
|
||||
|
@ -150,6 +150,10 @@ namespace cryptonote
|
||||
r = m_blockchain_storage.init(m_config_folder, testnet);
|
||||
CHECK_AND_ASSERT_MES(r, false, "Failed to initialize blockchain storage");
|
||||
|
||||
// load json & DNS checkpoints, and verify them
|
||||
// with respect to what blocks we already have
|
||||
update_checkpoints();
|
||||
|
||||
r = m_miner.init(vm, testnet);
|
||||
CHECK_AND_ASSERT_MES(r, false, "Failed to initialize blockchain storage");
|
||||
|
||||
|
@ -221,8 +221,6 @@ int main(int argc, char* argv[])
|
||||
} else {
|
||||
ccore.set_checkpoints(std::move(checkpoints));
|
||||
ccore.set_checkpoints_file_path(checkpoint_json_hashfile_fullpath.string());
|
||||
res = ccore.update_checkpoints();
|
||||
CHECK_AND_ASSERT_MES(res, 1, "Failed to load initial checkpoints");
|
||||
}
|
||||
|
||||
cryptonote::t_cryptonote_protocol_handler<cryptonote::core> cprotocol(ccore, NULL);
|
||||
|
Loading…
Reference in New Issue
Block a user