fuzz: Reset dirty connman state in process_message(s) targets

This commit is contained in:
MarcoFalke
2025-06-27 17:35:32 +02:00
parent fa11eea405
commit aeeeeec9f7
4 changed files with 16 additions and 0 deletions

View File

@@ -60,6 +60,8 @@ FUZZ_TARGET(process_message, .init = initialize_process_message)
FuzzedDataProvider fuzzed_data_provider(buffer.data(), buffer.size());
auto& connman = static_cast<ConnmanTestMsg&>(*g_setup->m_node.connman);
connman.ResetAddrCache();
connman.ResetMaxOutboundCycle();
auto& chainman = static_cast<TestChainstateManager&>(*g_setup->m_node.chainman);
SetMockTime(1610000000); // any time to successfully reset ibd
chainman.ResetIbd();

View File

@@ -50,6 +50,8 @@ FUZZ_TARGET(process_messages, .init = initialize_process_messages)
FuzzedDataProvider fuzzed_data_provider(buffer.data(), buffer.size());
auto& connman = static_cast<ConnmanTestMsg&>(*g_setup->m_node.connman);
connman.ResetAddrCache();
connman.ResetMaxOutboundCycle();
auto& chainman = static_cast<TestChainstateManager&>(*g_setup->m_node.chainman);
SetMockTime(1610000000); // any time to successfully reset ibd
chainman.ResetIbd();

View File

@@ -71,6 +71,15 @@ void ConnmanTestMsg::Handshake(CNode& node,
}
}
void ConnmanTestMsg::ResetAddrCache() { m_addr_response_caches = {}; }
void ConnmanTestMsg::ResetMaxOutboundCycle()
{
LOCK(m_total_bytes_sent_mutex);
nMaxOutboundCycleStartTime = 0s;
nMaxOutboundTotalBytesSentInCycle = 0;
}
void ConnmanTestMsg::NodeReceiveMsgBytes(CNode& node, std::span<const uint8_t> msg_bytes, bool& complete) const
{
assert(node.ReceiveMsgBytes(msg_bytes, complete));

View File

@@ -45,6 +45,9 @@ struct ConnmanTestMsg : public CConnman {
m_peer_connect_timeout = timeout;
}
void ResetAddrCache();
void ResetMaxOutboundCycle();
std::vector<CNode*> TestNodes()
{
LOCK(m_nodes_mutex);