From a2daef29857e7f64a4f5dc7c196a5bbe8e11367b Mon Sep 17 00:00:00 2001 From: tywald Date: Sun, 23 Oct 2022 19:40:41 +0200 Subject: [PATCH] service/nwm_uds: log instead of assert to prevent crashes during multiplayer in Monster Hunter games (#6161) --- src/core/hle/service/nwm/nwm_uds.cpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/core/hle/service/nwm/nwm_uds.cpp b/src/core/hle/service/nwm/nwm_uds.cpp index 05bff94551..4f287661e4 100644 --- a/src/core/hle/service/nwm/nwm_uds.cpp +++ b/src/core/hle/service/nwm/nwm_uds.cpp @@ -491,7 +491,10 @@ void NWM_UDS::HandleDeauthenticationFrame(const Network::WifiPacket& packet) { auto node_it = std::find_if(node_info.begin(), node_info.end(), [&node](const NodeInfo& info) { return info.network_node_id == node.node_id; }); - ASSERT(node_it != node_info.end()); + if (node_it == node_info.end()) { + LOG_ERROR(Service_NWM, "node_it is last node of node_info"); + return; + } connection_status.node_bitmask &= ~(1 << (node.node_id - 1)); connection_status.changed_nodes |= 1 << (node.node_id - 1); @@ -1096,9 +1099,6 @@ void NWM_UDS::SendTo(Kernel::HLERequestContext& ctx) { u32 data_size = rp.Pop(); u8 flags = rp.Pop(); - // There should never be a dest_node_id of 0 - ASSERT(dest_node_id != 0); - std::vector input_buffer = rp.PopStaticBuffer(); ASSERT(input_buffer.size() >= data_size); input_buffer.resize(data_size); @@ -1113,6 +1113,14 @@ void NWM_UDS::SendTo(Kernel::HLERequestContext& ctx) { return; } + // There should never be a dest_node_id of 0 + if (dest_node_id == 0) { + rb.Push(ResultCode(ErrorDescription::NotFound, ErrorModule::UDS, + ErrorSummary::WrongArgument, ErrorLevel::Status)); + LOG_ERROR(Service_NWM, "dest_node_id is 0"); + return; + } + if (dest_node_id == connection_status.network_node_id) { LOG_ERROR(Service_NWM, "tried to send packet to itself"); rb.Push(ResultCode(ErrorDescription::NotFound, ErrorModule::UDS,