From 46d6fa35c9c3f5257a31bc4dae89a102a441831b Mon Sep 17 00:00:00 2001 From: moneromooo-monero Date: Thu, 7 Dec 2017 22:22:14 +0000 Subject: [PATCH] cryptonote_protocol: sanity check chain hashes from peer --- src/cryptonote_protocol/cryptonote_protocol_handler.inl | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/cryptonote_protocol/cryptonote_protocol_handler.inl b/src/cryptonote_protocol/cryptonote_protocol_handler.inl index dbcc4eba1..de30df5d7 100644 --- a/src/cryptonote_protocol/cryptonote_protocol_handler.inl +++ b/src/cryptonote_protocol/cryptonote_protocol_handler.inl @@ -1585,6 +1585,12 @@ skip: drop_connection(context, true, false); return 1; } + if (arg.total_height < arg.m_block_ids.size() || arg.start_height > arg.total_height - arg.m_block_ids.size()) + { + LOG_ERROR_CCONTEXT("sent invalid start/nblocks/height, dropping connection"); + drop_connection(context, true, false); + return 1; + } context.m_remote_blockchain_height = arg.total_height; context.m_last_response_height = arg.start_height + arg.m_block_ids.size()-1;