mirror of
https://git.wownero.com/wownero/wownero.git
synced 2024-08-15 01:03:23 +00:00
protocol: more restrictive checks on chain entry response
This commit is contained in:
parent
065bb292df
commit
f47f1a0691
1 changed files with 8 additions and 1 deletions
|
@ -2428,7 +2428,7 @@ skip:
|
||||||
drop_connection(context, true, false);
|
drop_connection(context, true, false);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
if (arg.total_height < arg.m_block_ids.size() || arg.start_height > arg.total_height - arg.m_block_ids.size())
|
if (arg.total_height < arg.m_block_ids.size() || arg.start_height > arg.total_height - arg.m_block_ids.size() || arg.start_height >= m_core.get_current_blockchain_height())
|
||||||
{
|
{
|
||||||
LOG_ERROR_CCONTEXT("sent invalid start/nblocks/height, dropping connection");
|
LOG_ERROR_CCONTEXT("sent invalid start/nblocks/height, dropping connection");
|
||||||
drop_connection(context, true, false);
|
drop_connection(context, true, false);
|
||||||
|
@ -2469,8 +2469,15 @@ skip:
|
||||||
|
|
||||||
context.m_needed_objects.clear();
|
context.m_needed_objects.clear();
|
||||||
uint64_t added = 0;
|
uint64_t added = 0;
|
||||||
|
std::unordered_set<crypto::hash> blocks_found;
|
||||||
for (size_t i = 0; i < arg.m_block_ids.size(); ++i)
|
for (size_t i = 0; i < arg.m_block_ids.size(); ++i)
|
||||||
{
|
{
|
||||||
|
if (!blocks_found.insert(arg.m_block_ids[i]).second)
|
||||||
|
{
|
||||||
|
LOG_ERROR_CCONTEXT("Duplicate blocks in chain entry response, dropping connection");
|
||||||
|
drop_connection(context, true, false);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
const uint64_t block_weight = arg.m_block_weights.empty() ? 0 : arg.m_block_weights[i];
|
const uint64_t block_weight = arg.m_block_weights.empty() ? 0 : arg.m_block_weights[i];
|
||||||
context.m_needed_objects.push_back(std::make_pair(arg.m_block_ids[i], block_weight));
|
context.m_needed_objects.push_back(std::make_pair(arg.m_block_ids[i], block_weight));
|
||||||
if (++added == n_use_blocks)
|
if (++added == n_use_blocks)
|
||||||
|
|
Loading…
Reference in a new issue