diff options
author | moneromooo-monero <moneromooo-monero@users.noreply.github.com> | 2021-01-03 01:35:46 +0000 |
---|---|---|
committer | moneromooo-monero <moneromooo-monero@users.noreply.github.com> | 2021-01-03 13:04:55 +0000 |
commit | 4e74385a1ae9eae4ae9e8d155dfd96978eb10e7a (patch) | |
tree | 1056d8682ae7c099f7c86b6cb4b39a9a30f2f107 /src/cryptonote_protocol/cryptonote_protocol_handler.inl | |
parent | Merge pull request #7250 (diff) | |
download | monero-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.inl | 9 |
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> |