aboutsummaryrefslogtreecommitdiff
path: root/src/cryptonote_protocol/cryptonote_protocol_handler.inl
diff options
context:
space:
mode:
authormoneromooo-monero <moneromooo-monero@users.noreply.github.com>2021-01-03 01:35:46 +0000
committermoneromooo-monero <moneromooo-monero@users.noreply.github.com>2021-01-03 13:04:55 +0000
commit4e74385a1ae9eae4ae9e8d155dfd96978eb10e7a (patch)
tree1056d8682ae7c099f7c86b6cb4b39a9a30f2f107 /src/cryptonote_protocol/cryptonote_protocol_handler.inl
parentMerge pull request #7250 (diff)
downloadmonero-4e74385a1ae9eae4ae9e8d155dfd96978eb10e7a.tar.xz
fix accessing an network address in a deleted context
Both drop_connection and add_host_fail can drop the connection, which invalidates the context, and thus the address it contains. Thanks to wfaressuissia[m] for lots of help and prodding when debugging this
Diffstat (limited to '')
-rw-r--r--src/cryptonote_protocol/cryptonote_protocol_handler.inl9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/cryptonote_protocol/cryptonote_protocol_handler.inl b/src/cryptonote_protocol/cryptonote_protocol_handler.inl
index bd39077ae..d6a08e21b 100644
--- a/src/cryptonote_protocol/cryptonote_protocol_handler.inl
+++ b/src/cryptonote_protocol/cryptonote_protocol_handler.inl
@@ -2835,12 +2835,15 @@ skip:
epee::string_tools::to_string_hex(context.m_pruning_seed) <<
"), score " << score << ", flush_all_spans " << flush_all_spans);
- if (score > 0)
- m_p2p->add_host_fail(context.m_remote_address, score);
-
m_block_queue.flush_spans(context.m_connection_id, flush_all_spans);
+ // copy since dropping the connection will invalidate the context, and thus the address
+ const auto remote_address = context.m_remote_address;
+
m_p2p->drop_connection(context);
+
+ if (score > 0)
+ m_p2p->add_host_fail(remote_address, score);
}
//------------------------------------------------------------------------------------------------------------------------
template<class t_core>