mirror of
https://codeberg.org/anoncontributorxmr/monero.git
synced 2024-11-23 18:47:36 -07:00
blockchain: avoid exception if asked for a block we do not have
This can happen if a peer tries to obtain the next span from other peers if that span is needed for not downloaded yet. Also if the peer maliciously requests a non existent block hash.
This commit is contained in:
parent
52f6b33890
commit
b5cb1bc403
@ -2032,15 +2032,18 @@ bool Blockchain::get_blocks(const t_ids_container& block_ids, t_blocks_container
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
blocks.push_back(std::make_pair(m_db->get_block_blob(block_hash), block()));
|
uint64_t height = 0;
|
||||||
|
if (m_db->block_exists(block_hash, &height))
|
||||||
|
{
|
||||||
|
blocks.push_back(std::make_pair(m_db->get_block_blob_from_height(height), block()));
|
||||||
if (!parse_and_validate_block_from_blob(blocks.back().first, blocks.back().second))
|
if (!parse_and_validate_block_from_blob(blocks.back().first, blocks.back().second))
|
||||||
{
|
{
|
||||||
LOG_ERROR("Invalid block");
|
LOG_ERROR("Invalid block: " << block_hash);
|
||||||
return false;
|
blocks.pop_back();
|
||||||
|
missed_bs.push_back(block_hash);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (const BLOCK_DNE& e)
|
else
|
||||||
{
|
|
||||||
missed_bs.push_back(block_hash);
|
missed_bs.push_back(block_hash);
|
||||||
}
|
}
|
||||||
catch (const std::exception& e)
|
catch (const std::exception& e)
|
||||||
|
Loading…
Reference in New Issue
Block a user