diff --git a/src/CryptoNoteConfig.h b/src/CryptoNoteConfig.h index e94fb4ae..44f43864 100644 --- a/src/CryptoNoteConfig.h +++ b/src/CryptoNoteConfig.h @@ -150,6 +150,7 @@ namespace CryptoNote const size_t BLOCKS_IDS_SYNCHRONIZING_DEFAULT_COUNT = 10000; // by default, blocks ids count in synchronizing const size_t BLOCKS_SYNCHRONIZING_DEFAULT_COUNT = 128; // by default, blocks count in blocks downloading const size_t COMMAND_RPC_GET_BLOCKS_FAST_MAX_COUNT = 1000; + const size_t COMMAND_RPC_GET_OBJECTS_MAX_COUNT = 1000; const int P2P_DEFAULT_PORT = 15000; const int RPC_DEFAULT_PORT = 16000; @@ -282,4 +283,4 @@ namespace CryptoNote } // namespace CryptoNote -#define ALLOW_DEBUG_COMMANDS \ No newline at end of file +#define ALLOW_DEBUG_COMMANDS diff --git a/src/CryptoNoteProtocol/CryptoNoteProtocolHandler.cpp b/src/CryptoNoteProtocol/CryptoNoteProtocolHandler.cpp index 13753b89..5a163fdf 100644 --- a/src/CryptoNoteProtocol/CryptoNoteProtocolHandler.cpp +++ b/src/CryptoNoteProtocol/CryptoNoteProtocolHandler.cpp @@ -395,11 +395,19 @@ int CryptoNoteProtocolHandler::handle_notify_new_transactions(int command, NOTIF int CryptoNoteProtocolHandler::handle_request_get_objects(int command, NOTIFY_REQUEST_GET_OBJECTS::request &arg, CryptoNoteConnectionContext &context) { logger(Logging::TRACE) << context << "NOTIFY_REQUEST_GET_OBJECTS"; + if(arg.blocks.size() > COMMAND_RPC_GET_OBJECTS_MAX_COUNT || arg.txs.size() > COMMAND_RPC_GET_OBJECTS_MAX_COUNT) + { + logger(Logging::ERROR) << context << "GET_OBJECTS_MAX_COUNT exceeded blocks: " << arg.blocks.size() << " txes: " << arg.txs.size(); + context.m_state = CryptoNoteConnectionContext::state_shutdown; + return 1; + } + NOTIFY_RESPONSE_GET_OBJECTS::request rsp; if (!m_core.handle_get_objects(arg, rsp)) { logger(Logging::ERROR) << context << "failed to handle request NOTIFY_REQUEST_GET_OBJECTS, dropping connection"; context.m_state = CryptoNoteConnectionContext::state_shutdown; + return 1; } logger(Logging::TRACE) << context << "-->>NOTIFY_RESPONSE_GET_OBJECTS: blocks.size()=" << rsp.blocks.size() << ", txs.size()=" << rsp.txs.size() << ", rsp.m_current_blockchain_height=" << rsp.current_blockchain_height << ", missed_ids.size()=" << rsp.missed_ids.size();