cryptonote_protocol: reject requests/notifications before handshake
Reported by xnbya
This commit is contained in:
parent
77a008f714
commit
bb5c5dff15
@ -793,6 +793,12 @@ namespace cryptonote
|
|||||||
int t_cryptonote_protocol_handler<t_core>::handle_request_fluffy_missing_tx(int command, NOTIFY_REQUEST_FLUFFY_MISSING_TX::request& arg, cryptonote_connection_context& context)
|
int t_cryptonote_protocol_handler<t_core>::handle_request_fluffy_missing_tx(int command, NOTIFY_REQUEST_FLUFFY_MISSING_TX::request& arg, cryptonote_connection_context& context)
|
||||||
{
|
{
|
||||||
MLOG_P2P_MESSAGE("Received NOTIFY_REQUEST_FLUFFY_MISSING_TX (" << arg.missing_tx_indices.size() << " txes), block hash " << arg.block_hash);
|
MLOG_P2P_MESSAGE("Received NOTIFY_REQUEST_FLUFFY_MISSING_TX (" << arg.missing_tx_indices.size() << " txes), block hash " << arg.block_hash);
|
||||||
|
if (context.m_state == cryptonote_connection_context::state_before_handshake)
|
||||||
|
{
|
||||||
|
LOG_ERROR_CCONTEXT("Requested fluffy tx before handshake, dropping connection");
|
||||||
|
drop_connection(context, false, false);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
std::vector<std::pair<cryptonote::blobdata, block>> local_blocks;
|
std::vector<std::pair<cryptonote::blobdata, block>> local_blocks;
|
||||||
std::vector<cryptonote::blobdata> local_txs;
|
std::vector<cryptonote::blobdata> local_txs;
|
||||||
@ -884,6 +890,8 @@ namespace cryptonote
|
|||||||
int t_cryptonote_protocol_handler<t_core>::handle_notify_get_txpool_complement(int command, NOTIFY_GET_TXPOOL_COMPLEMENT::request& arg, cryptonote_connection_context& context)
|
int t_cryptonote_protocol_handler<t_core>::handle_notify_get_txpool_complement(int command, NOTIFY_GET_TXPOOL_COMPLEMENT::request& arg, cryptonote_connection_context& context)
|
||||||
{
|
{
|
||||||
MLOG_P2P_MESSAGE("Received NOTIFY_GET_TXPOOL_COMPLEMENT (" << arg.hashes.size() << " txes)");
|
MLOG_P2P_MESSAGE("Received NOTIFY_GET_TXPOOL_COMPLEMENT (" << arg.hashes.size() << " txes)");
|
||||||
|
if(context.m_state != cryptonote_connection_context::state_normal)
|
||||||
|
return 1;
|
||||||
|
|
||||||
std::vector<std::pair<cryptonote::blobdata, block>> local_blocks;
|
std::vector<std::pair<cryptonote::blobdata, block>> local_blocks;
|
||||||
std::vector<cryptonote::blobdata> local_txs;
|
std::vector<cryptonote::blobdata> local_txs;
|
||||||
@ -987,6 +995,12 @@ namespace cryptonote
|
|||||||
template<class t_core>
|
template<class t_core>
|
||||||
int t_cryptonote_protocol_handler<t_core>::handle_request_get_objects(int command, NOTIFY_REQUEST_GET_OBJECTS::request& arg, cryptonote_connection_context& context)
|
int t_cryptonote_protocol_handler<t_core>::handle_request_get_objects(int command, NOTIFY_REQUEST_GET_OBJECTS::request& arg, cryptonote_connection_context& context)
|
||||||
{
|
{
|
||||||
|
if (context.m_state == cryptonote_connection_context::state_before_handshake)
|
||||||
|
{
|
||||||
|
LOG_ERROR_CCONTEXT("Requested objects before handshake, dropping connection");
|
||||||
|
drop_connection(context, false, false);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
MLOG_P2P_MESSAGE("Received NOTIFY_REQUEST_GET_OBJECTS (" << arg.blocks.size() << " blocks)");
|
MLOG_P2P_MESSAGE("Received NOTIFY_REQUEST_GET_OBJECTS (" << arg.blocks.size() << " blocks)");
|
||||||
if (arg.blocks.size() > CURRENCY_PROTOCOL_MAX_OBJECT_REQUEST_COUNT)
|
if (arg.blocks.size() > CURRENCY_PROTOCOL_MAX_OBJECT_REQUEST_COUNT)
|
||||||
{
|
{
|
||||||
@ -1717,6 +1731,12 @@ skip:
|
|||||||
int t_cryptonote_protocol_handler<t_core>::handle_request_chain(int command, NOTIFY_REQUEST_CHAIN::request& arg, cryptonote_connection_context& context)
|
int t_cryptonote_protocol_handler<t_core>::handle_request_chain(int command, NOTIFY_REQUEST_CHAIN::request& arg, cryptonote_connection_context& context)
|
||||||
{
|
{
|
||||||
MLOG_P2P_MESSAGE("Received NOTIFY_REQUEST_CHAIN (" << arg.block_ids.size() << " blocks");
|
MLOG_P2P_MESSAGE("Received NOTIFY_REQUEST_CHAIN (" << arg.block_ids.size() << " blocks");
|
||||||
|
if (context.m_state == cryptonote_connection_context::state_before_handshake)
|
||||||
|
{
|
||||||
|
LOG_ERROR_CCONTEXT("Requested chain before handshake, dropping connection");
|
||||||
|
drop_connection(context, false, false);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
NOTIFY_RESPONSE_CHAIN_ENTRY::request r;
|
NOTIFY_RESPONSE_CHAIN_ENTRY::request r;
|
||||||
if(!m_core.find_blockchain_supplement(arg.block_ids, !arg.prune, r))
|
if(!m_core.find_blockchain_supplement(arg.block_ids, !arg.prune, r))
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user