mirror of
https://github.com/monero-project/monero.git
synced 2024-11-17 16:27:39 +00:00
cryptonote_protocol: fix another potential P2P DoS
When asking for txes in a fluffy transaction, one might ask for the same (large) tx many times
This commit is contained in:
parent
1cc61018e5
commit
68ad548193
1 changed files with 15 additions and 0 deletions
|
@ -809,12 +809,27 @@ namespace cryptonote
|
||||||
NOTIFY_NEW_FLUFFY_BLOCK::request fluffy_response;
|
NOTIFY_NEW_FLUFFY_BLOCK::request fluffy_response;
|
||||||
fluffy_response.b.block = t_serializable_object_to_blob(b);
|
fluffy_response.b.block = t_serializable_object_to_blob(b);
|
||||||
fluffy_response.current_blockchain_height = arg.current_blockchain_height;
|
fluffy_response.current_blockchain_height = arg.current_blockchain_height;
|
||||||
|
std::vector<bool> seen(b.tx_hashes.size(), false);
|
||||||
for(auto& tx_idx: arg.missing_tx_indices)
|
for(auto& tx_idx: arg.missing_tx_indices)
|
||||||
{
|
{
|
||||||
if(tx_idx < b.tx_hashes.size())
|
if(tx_idx < b.tx_hashes.size())
|
||||||
{
|
{
|
||||||
MDEBUG(" tx " << b.tx_hashes[tx_idx]);
|
MDEBUG(" tx " << b.tx_hashes[tx_idx]);
|
||||||
|
if (seen[tx_idx])
|
||||||
|
{
|
||||||
|
LOG_ERROR_CCONTEXT
|
||||||
|
(
|
||||||
|
"Failed to handle request NOTIFY_REQUEST_FLUFFY_MISSING_TX"
|
||||||
|
<< ", request is asking for duplicate tx "
|
||||||
|
<< ", tx index = " << tx_idx << ", block tx count " << b.tx_hashes.size()
|
||||||
|
<< ", block_height = " << arg.current_blockchain_height
|
||||||
|
<< ", dropping connection"
|
||||||
|
);
|
||||||
|
drop_connection(context, true, false);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
txids.push_back(b.tx_hashes[tx_idx]);
|
txids.push_back(b.tx_hashes[tx_idx]);
|
||||||
|
seen[tx_idx] = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue